├── docs └── .keep ├── config ├── multiverse-square.png ├── multiverse2-long.png ├── multiverse2-short.png ├── multiverse-square-trans.png └── multiverse2-short-small.png ├── libs └── FoliaLib-1.0-SNAPSHOT.jar ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src └── main │ ├── java │ └── com │ │ └── onarandombox │ │ └── MultiverseCore │ │ ├── enums │ │ ├── package-info.java │ │ ├── RespawnType.java │ │ ├── AddProperties.java │ │ ├── Action.java │ │ ├── TeleportResult.java │ │ ├── EnglishChatStyle.java │ │ ├── AllowedPortalType.java │ │ └── EnglishChatColor.java │ │ ├── event │ │ ├── package-info.java │ │ ├── MVDebugModeEvent.java │ │ ├── MVConfigReloadEvent.java │ │ ├── MVWorldDeleteEvent.java │ │ ├── MVRespawnEvent.java │ │ └── MVPlayerTouchedPortalEvent.java │ │ ├── commands │ │ ├── package-info.java │ │ ├── PaginatedCoreCommand.java │ │ ├── MultiverseCommand.java │ │ ├── SleepCommand.java │ │ ├── ConfirmCommand.java │ │ ├── UnloadCommand.java │ │ ├── RemoveCommand.java │ │ ├── LoadCommand.java │ │ ├── SilentCommand.java │ │ ├── ReloadCommand.java │ │ ├── ScriptCommand.java │ │ ├── CloneCommand.java │ │ ├── GeneratorCommand.java │ │ ├── DeleteCommand.java │ │ ├── DebugCommand.java │ │ ├── CheckCommand.java │ │ ├── ModifyCommand.java │ │ ├── CoordCommand.java │ │ └── ConfigCommand.java │ │ ├── listeners │ │ ├── package-info.java │ │ ├── ChatEvent.java │ │ ├── AsyncChatEvent.java │ │ ├── NormalChatEvent.java │ │ ├── MVWorldInitListener.java │ │ ├── MVAsyncPlayerChatListener.java │ │ ├── MVPlayerChatListener.java │ │ ├── MVMapListener.java │ │ ├── MVWeatherListener.java │ │ ├── MVChatListener.java │ │ ├── MVWorldListener.java │ │ └── MultiverseCoreListener.java │ │ ├── utils │ │ ├── package-info.java │ │ ├── webpaste │ │ │ ├── package-info.java │ │ │ ├── URLShortenerType.java │ │ │ ├── PasteFailedException.java │ │ │ ├── PasteServiceType.java │ │ │ ├── URLShortenerFactory.java │ │ │ ├── URLShortener.java │ │ │ ├── PasteServiceFactory.java │ │ │ ├── BitlyURLShortener.java │ │ │ ├── PasteService.java │ │ │ ├── HastebinPasteService.java │ │ │ ├── PastebinPasteService.java │ │ │ ├── PasteGGPasteService.java │ │ │ └── GitHubPasteService.java │ │ ├── TestingMode.java │ │ ├── MVTravelAgent.java │ │ ├── metrics │ │ │ ├── MetricsHelper.java │ │ │ └── MetricsConfigurator.java │ │ ├── FancyHeader.java │ │ ├── MaterialConverter.java │ │ ├── TeleportUtil.java │ │ ├── MVPlayerSession.java │ │ ├── UnsafeCallWrapper.java │ │ ├── FancyColorScheme.java │ │ ├── FancyMessage.java │ │ ├── VaultHandler.java │ │ └── MVMessaging.java │ │ ├── exceptions │ │ ├── package-info.java │ │ └── PropertyDoesNotExistException.java │ │ ├── destination │ │ ├── package-info.java │ │ ├── CustomTeleporterDestination.java │ │ └── InvalidDestination.java │ │ ├── package-info.java │ │ ├── configuration │ │ ├── package-info.java │ │ ├── WorldPropertyValidator.java │ │ ├── SpawnSettings.java │ │ ├── SubSpawnSettings.java │ │ ├── EntryFee.java │ │ └── SpawnLocation.java │ │ ├── commandtools │ │ └── queue │ │ │ ├── package-info.java │ │ │ ├── QueuedCommand.java │ │ │ └── DummyCommandBlockSender.java │ │ ├── api │ │ ├── package-info.java │ │ ├── Teleporter.java │ │ ├── FancyText.java │ │ ├── LoggablePlugin.java │ │ ├── MVPlugin.java │ │ ├── MultiverseMessaging.java │ │ ├── SafeTTeleporter.java │ │ ├── BlockSafety.java │ │ ├── WorldPurger.java │ │ └── LocationManipulation.java │ │ └── display │ │ ├── ColorTool.java │ │ ├── settings │ │ ├── DisplaySetting.java │ │ ├── InlineDisplaySettings.java │ │ ├── MapDisplaySettings.java │ │ └── PagedDisplaySettings.java │ │ ├── DisplayFormatException.java │ │ ├── handlers │ │ ├── ListDisplayHandler.java │ │ ├── InlineListDisplayHandler.java │ │ └── InlineMapDisplayHandler.java │ │ ├── ColorAlternator.java │ │ ├── DisplayHandlers.java │ │ └── DisplayHandler.java │ └── resources │ └── defaults │ └── config.yml ├── .github ├── workflows │ ├── pr.checkstyle.yml │ ├── pr.test.yml │ ├── generic.checkstyle.yml │ ├── pr.require_label.yml │ ├── main.prerelease.yml │ ├── dispatch.platform_uploads.yml │ ├── call.github_release.yml │ ├── dispatch.promote_release.yml │ ├── generic.test.yml │ ├── dispatch.javadoc.yml │ └── call.platform_uploads.yml └── ISSUE_TEMPLATE │ ├── config.yml │ ├── feature-request.yml │ └── bug-report.yml ├── settings.gradle ├── .gitignore ├── LICENSE.md └── gradlew.bat /docs/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /config/multiverse-square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenYuan-MC/Multiverse-Core_Zeta/HEAD/config/multiverse-square.png -------------------------------------------------------------------------------- /config/multiverse2-long.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenYuan-MC/Multiverse-Core_Zeta/HEAD/config/multiverse2-long.png -------------------------------------------------------------------------------- /config/multiverse2-short.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenYuan-MC/Multiverse-Core_Zeta/HEAD/config/multiverse2-short.png -------------------------------------------------------------------------------- /libs/FoliaLib-1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenYuan-MC/Multiverse-Core_Zeta/HEAD/libs/FoliaLib-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenYuan-MC/Multiverse-Core_Zeta/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /config/multiverse-square-trans.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenYuan-MC/Multiverse-Core_Zeta/HEAD/config/multiverse-square-trans.png -------------------------------------------------------------------------------- /config/multiverse2-short-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenYuan-MC/Multiverse-Core_Zeta/HEAD/config/multiverse2-short-small.png -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/enums/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all enums. 3 | */ 4 | package com.onarandombox.MultiverseCore.enums; 5 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/event/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all events. 3 | */ 4 | package com.onarandombox.MultiverseCore.event; 5 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all Commands. 3 | */ 4 | package com.onarandombox.MultiverseCore.commands; 5 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/listeners/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all listeners. 3 | */ 4 | package com.onarandombox.MultiverseCore.listeners; 5 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all Utility-clases. 3 | */ 4 | package com.onarandombox.MultiverseCore.utils; 5 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/exceptions/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all exceptions. 3 | */ 4 | package com.onarandombox.MultiverseCore.exceptions; 5 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/destination/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all destination-types. 3 | */ 4 | package com.onarandombox.MultiverseCore.destination; 5 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/enums/RespawnType.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.enums; 2 | 3 | public enum RespawnType { 4 | BED, 5 | ANCHOR, 6 | OTHER 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The "master"-package, containing everything related to Multiverse-Core. 3 | */ 4 | package com.onarandombox.MultiverseCore; 5 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains webpaste-utilities. 3 | */ 4 | package com.onarandombox.MultiverseCore.utils.webpaste; 5 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/configuration/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains the Multiverse-configuration. 3 | */ 4 | package com.onarandombox.MultiverseCore.configuration; 5 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commandtools/queue/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Manager queuing of dangerous commands in need of confirmation. 3 | */ 4 | package com.onarandombox.MultiverseCore.commandtools.queue; -------------------------------------------------------------------------------- /.github/workflows/pr.checkstyle.yml: -------------------------------------------------------------------------------- 1 | name: 'PR: Checkstyle' 2 | 3 | on: 4 | pull_request: 5 | types: [opened, synchronize] 6 | 7 | jobs: 8 | checkstyle: 9 | uses: ./.github/workflows/generic.checkstyle.yml 10 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | */ 4 | 5 | pluginManagement { 6 | repositories { 7 | gradlePluginPortal() 8 | } 9 | } 10 | 11 | rootProject.name = 'multiverse-core' 12 | -------------------------------------------------------------------------------- /.github/workflows/pr.test.yml: -------------------------------------------------------------------------------- 1 | name: 'PR: Test' 2 | 3 | on: 4 | pull_request: 5 | types: [opened, synchronize] 6 | 7 | jobs: 8 | test: 9 | uses: ./.github/workflows/generic.test.yml 10 | with: 11 | plugin_name: multiverse-core 12 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/api/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The Multiverse-API, containing lots of interfaces that can be quite useful for other 3 | * plugins when interacting with Multiverse. 4 | */ 5 | package com.onarandombox.MultiverseCore.api; 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: 💬 Multiverse Discord Server 4 | url: https://discord.gg/NZtfKky 5 | about: Need help with using Multiverse-Core or just want to chat with the devs? Join the Multiverse Discord Server for help! 6 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/URLShortenerType.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils.webpaste; 2 | 3 | /** 4 | * An enum containing all known {@link URLShortener}s. 5 | * 6 | * @see URLShortener 7 | * @see URLShortenerFactory 8 | */ 9 | public enum URLShortenerType { 10 | /** 11 | * @see BitlyURLShortener 12 | */ 13 | BITLY 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/PasteFailedException.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils.webpaste; 2 | 3 | /** 4 | * Thrown when pasting fails. 5 | */ 6 | public class PasteFailedException extends Exception { 7 | public PasteFailedException() { 8 | super(); 9 | } 10 | 11 | public PasteFailedException(Throwable cause) { 12 | super(cause); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.github/workflows/generic.checkstyle.yml: -------------------------------------------------------------------------------- 1 | name: 'Generic: Checkstyle' 2 | 3 | on: 4 | workflow_call: 5 | 6 | jobs: 7 | checkstyle: 8 | runs-on: ubuntu-latest 9 | permissions: 10 | contents: read 11 | steps: 12 | - uses: actions/checkout@v3 13 | 14 | - uses: dbelyaev/action-checkstyle@v0.8.4 15 | with: 16 | github_token: ${{ secrets.GITHUB_TOKEN }} 17 | checkstyle_version: 10.12.2 18 | checkstyle_config: ./config/mv_checks.xml 19 | -------------------------------------------------------------------------------- /.github/workflows/pr.require_label.yml: -------------------------------------------------------------------------------- 1 | name: 'PR: Require Label' 2 | 3 | on: 4 | pull_request: 5 | types: [opened, labeled, unlabeled, synchronize] 6 | branches: [main] 7 | 8 | jobs: 9 | require_label: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: mheap/github-action-required-labels@v2 13 | env: 14 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 15 | with: 16 | mode: exactly 17 | count: 1 18 | labels: "release:major, release:minor, release:patch, no release" 19 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/api/Teleporter.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.api; 2 | 3 | import com.onarandombox.MultiverseCore.api.MVDestination; 4 | import com.onarandombox.MultiverseCore.enums.TeleportResult; 5 | import org.bukkit.command.CommandSender; 6 | import org.bukkit.entity.Player; 7 | 8 | import java.util.concurrent.CompletableFuture; 9 | 10 | public interface Teleporter { 11 | CompletableFuture teleport(CommandSender teleporter, Player teleportee, MVDestination destination); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/display/ColorTool.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.display; 2 | 3 | import org.bukkit.ChatColor; 4 | 5 | /** 6 | * Tools to allow customisation. 7 | */ 8 | @FunctionalInterface 9 | public interface ColorTool { 10 | 11 | /** 12 | * Gets a chat color. 13 | * 14 | * @return The color. 15 | */ 16 | ChatColor get(); 17 | 18 | /** 19 | * Default implementation of this interface. Returns a default white color. 20 | */ 21 | ColorTool DEFAULT = () -> ChatColor.WHITE; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/TestingMode.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils; 2 | 3 | /** 4 | * A utility class that enables automated tests to flag Multiverse for testing. This allows Multiverse to not perform 5 | * certain behaviors such as enabled stats uploads. 6 | */ 7 | public class TestingMode { 8 | 9 | private static boolean enabled = false; 10 | 11 | public static void enable() { 12 | enabled = true; 13 | } 14 | 15 | public static boolean isDisabled() { 16 | return !enabled; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/display/settings/DisplaySetting.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.display.settings; 2 | 3 | import com.onarandombox.MultiverseCore.display.DisplayHandler; 4 | 5 | /** 6 | * Represents a setting option that can be used by {@link DisplayHandler}. 7 | * 8 | * @param 9 | */ 10 | @FunctionalInterface 11 | public interface DisplaySetting { 12 | 13 | /** 14 | * Gets the default value of this Display Setting. 15 | * 16 | * @return The default value. 17 | */ 18 | T defaultValue(); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/display/settings/InlineDisplaySettings.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.display.settings; 2 | 3 | import com.onarandombox.MultiverseCore.display.DisplayHandler; 4 | import org.bukkit.ChatColor; 5 | 6 | /** 7 | * Collection of {@link DisplaySetting} that are used by various {@link DisplayHandler}. 8 | */ 9 | public class InlineDisplaySettings { 10 | 11 | /** 12 | * Inline separator. E.g. '1, 2, 3' 13 | */ 14 | public static final DisplaySetting SEPARATOR = () -> ChatColor.WHITE + ", "; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/display/settings/MapDisplaySettings.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.display.settings; 2 | 3 | import com.onarandombox.MultiverseCore.display.DisplayHandler; 4 | import org.bukkit.ChatColor; 5 | 6 | /** 7 | * Collection of {@link DisplaySetting} that are used by various {@link DisplayHandler}. 8 | */ 9 | public class MapDisplaySettings { 10 | 11 | /** 12 | * The thing between a key value pair. E.g. 'Me = Smart' 13 | */ 14 | public static final DisplaySetting OPERATOR = () -> ChatColor.WHITE + " = "; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/PasteServiceType.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils.webpaste; 2 | 3 | /** 4 | * An enum containing all known {@link PasteService}s. 5 | * 6 | * @see PasteService 7 | * @see PasteServiceFactory 8 | */ 9 | public enum PasteServiceType { 10 | /** 11 | * @see PasteGGPasteService 12 | */ 13 | PASTEGG, 14 | /** 15 | * @see PastebinPasteService 16 | */ 17 | PASTEBIN, 18 | /** 19 | * @see HastebinPasteService 20 | */ 21 | HASTEBIN, 22 | /** 23 | * @see GitHubPasteService 24 | */ 25 | GITHUB 26 | } 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse stuff 2 | /.classpath 3 | /.project 4 | /.settings 5 | /.checkstyle 6 | 7 | # netbeans 8 | /nbproject 9 | 10 | # we use maven! 11 | /build.xml 12 | 13 | # maven 14 | /target 15 | dependency-reduced-pom.xml 16 | 17 | # vim 18 | .*.sw[a-p] 19 | 20 | # various other potential build files 21 | /build 22 | /bin 23 | /dist 24 | /manifest.mf 25 | 26 | /world 27 | 28 | # Mac filesystem dust 29 | *.DS_Store 30 | 31 | # intellij 32 | *.iml 33 | *.ipr 34 | *.iws 35 | .idea/ 36 | 37 | # Fern's utils 38 | uploadtoserver.sh 39 | 40 | # Testing files: 41 | debug.log 42 | 43 | # Doxygen 44 | /docs/html 45 | debug.txt 46 | 47 | # Gradle 48 | .gradle 49 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/listeners/ChatEvent.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.listeners; 2 | 3 | import org.bukkit.entity.Player; 4 | 5 | /** 6 | * A wrapper for the two chat-events in Bukkit. 7 | */ 8 | public interface ChatEvent { 9 | /** 10 | * @return Whether this event is cancelled. 11 | */ 12 | boolean isCancelled(); 13 | 14 | /** 15 | * @return The format. 16 | */ 17 | String getFormat(); 18 | 19 | /** 20 | * Sets the format. 21 | * @param s The new format. 22 | */ 23 | void setFormat(String s); 24 | 25 | /** 26 | * @return The player. 27 | */ 28 | Player getPlayer(); 29 | } 30 | -------------------------------------------------------------------------------- /.github/workflows/main.prerelease.yml: -------------------------------------------------------------------------------- 1 | name: 'Main: Prerelease' 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | 7 | jobs: 8 | github_release_on_push: 9 | uses: ./.github/workflows/call.github_release.yml 10 | secrets: inherit 11 | with: 12 | release_mode: prerelease 13 | version_bump: prlabel 14 | 15 | platform_uploads_on_push: 16 | needs: github_release_on_push 17 | if: needs.github_release_on_push.outputs.release_created == 'true' 18 | uses: ./.github/workflows/call.platform_uploads.yml 19 | secrets: inherit 20 | with: 21 | target_tag: ${{ needs.github_release_on_push.outputs.tag_name }} 22 | upload_modrinth: 'true' 23 | upload_dbo: 'false' 24 | upload_hangar: 'false' 25 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/URLShortenerFactory.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils.webpaste; 2 | 3 | /** 4 | * Used to construct {@link URLShortener}s. 5 | */ 6 | public class URLShortenerFactory { 7 | private URLShortenerFactory() { } 8 | 9 | /** 10 | * Constructs a new {@link URLShortener}. 11 | * @param type The {@link URLShortenerType}. 12 | * @return The newly created {@link URLShortener}. 13 | */ 14 | public static URLShortener getService(URLShortenerType type) { 15 | if (type == URLShortenerType.BITLY) { 16 | try { 17 | return new BitlyURLShortener(); 18 | } catch (UnsupportedOperationException ignored) {} 19 | } 20 | 21 | return null; 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/display/DisplayFormatException.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.display; 2 | 3 | /** 4 | * Thrown when an issue occur while formatting content. 5 | */ 6 | public class DisplayFormatException extends Exception { 7 | public DisplayFormatException() { 8 | } 9 | 10 | public DisplayFormatException(String message) { 11 | super(message); 12 | } 13 | 14 | public DisplayFormatException(String message, Throwable cause) { 15 | super(message, cause); 16 | } 17 | 18 | public DisplayFormatException(Throwable cause) { 19 | super(cause); 20 | } 21 | 22 | public DisplayFormatException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 23 | super(message, cause, enableSuppression, writableStackTrace); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/URLShortener.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils.webpaste; 2 | 3 | /** 4 | * An interface to a web-based URL Shortener. Classes extending this should 5 | * implement its methods to shorten links using the service. Given some 6 | * URLShortener instance us, a URL is shortened by: 7 | * 8 | * {@code us.shorten(longUrl);} 9 | * 10 | * An example of this, is the BitlyURLShortener. 11 | */ 12 | public abstract class URLShortener extends HttpAPIClient { 13 | URLShortener(String url) { 14 | super(url); 15 | } 16 | 17 | URLShortener(String url, String accessToken) { 18 | super(url, accessToken); 19 | } 20 | 21 | /** 22 | * Shorten a URL. 23 | * @param longUrl The long form. 24 | * @return The shortened URL. 25 | */ 26 | public abstract String shorten(String longUrl); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/api/FancyText.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.api; 9 | 10 | /** 11 | * A fancy text. 12 | */ 13 | public interface FancyText { 14 | /** 15 | * Gets the {@link String}-representation of this {@link FancyText}. 16 | * 17 | * @return The {@link String}-representation of this {@link FancyText}. 18 | */ 19 | String getFancyText(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/listeners/AsyncChatEvent.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.listeners; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.player.AsyncPlayerChatEvent; 5 | 6 | /** 7 | * A wrapper for the {@link AsyncPlayerChatEvent}. 8 | */ 9 | public class AsyncChatEvent implements ChatEvent { 10 | private final AsyncPlayerChatEvent event; 11 | 12 | public AsyncChatEvent(AsyncPlayerChatEvent event) { 13 | this.event = event; 14 | } 15 | 16 | @Override 17 | public boolean isCancelled() { 18 | return event.isCancelled(); 19 | } 20 | 21 | @Override 22 | public String getFormat() { 23 | return event.getFormat(); 24 | } 25 | 26 | @Override 27 | public void setFormat(String s) { 28 | event.setFormat(s); 29 | } 30 | 31 | @Override 32 | public Player getPlayer() { 33 | return event.getPlayer(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/enums/AddProperties.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.enums; 9 | 10 | /** 11 | * An enum containing all list-properties. 12 | */ 13 | public enum AddProperties { 14 | /** 15 | * Worlds that people cannot go to from a world. 16 | */ 17 | worldblacklist, 18 | /** 19 | * Animal-exceptions. 20 | */ 21 | animals, 22 | /** 23 | * Monster-exceptions. 24 | */ 25 | monsters 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/destination/CustomTeleporterDestination.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.destination; 2 | 3 | import com.onarandombox.MultiverseCore.api.Teleporter; 4 | import com.onarandombox.MultiverseCore.api.MVDestination; 5 | import org.bukkit.Location; 6 | import org.bukkit.entity.Entity; 7 | import org.bukkit.util.Vector; 8 | 9 | public abstract class CustomTeleporterDestination implements MVDestination { 10 | @Override 11 | public final Location getLocation(final Entity entity) { 12 | throw new UnsupportedOperationException(); 13 | } 14 | 15 | @Override 16 | public final Vector getVelocity() { 17 | throw new UnsupportedOperationException(); 18 | } 19 | 20 | @Override 21 | public final boolean useSafeTeleporter() { 22 | throw new UnsupportedOperationException(); 23 | } 24 | 25 | @Override 26 | public abstract String toString(); 27 | 28 | public abstract Teleporter getTeleporter(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/exceptions/PropertyDoesNotExistException.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.exceptions; 9 | 10 | /** 11 | * Thrown when a world-property doesn't exist. 12 | */ 13 | public class PropertyDoesNotExistException extends Exception { 14 | public PropertyDoesNotExistException(String name) { 15 | super(name); 16 | } 17 | 18 | public PropertyDoesNotExistException(String name, Throwable cause) { 19 | super(name, cause); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/listeners/NormalChatEvent.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.listeners; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.player.PlayerChatEvent; 5 | 6 | /** 7 | * A wrapper for the {@link PlayerChatEvent}. 8 | * @deprecated This is deprecated like the {@link PlayerChatEvent}. 9 | */ 10 | @Deprecated 11 | public class NormalChatEvent implements ChatEvent { 12 | private final PlayerChatEvent event; 13 | 14 | public NormalChatEvent(PlayerChatEvent event) { 15 | this.event = event; 16 | } 17 | 18 | @Override 19 | public boolean isCancelled() { 20 | return event.isCancelled(); 21 | } 22 | 23 | @Override 24 | public String getFormat() { 25 | return event.getFormat(); 26 | } 27 | 28 | @Override 29 | public void setFormat(String s) { 30 | event.setFormat(s); 31 | } 32 | 33 | @Override 34 | public Player getPlayer() { 35 | return event.getPlayer(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/display/settings/PagedDisplaySettings.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.display.settings; 2 | 3 | public class PagedDisplaySettings { 4 | 5 | /** 6 | * Page to display. 7 | */ 8 | public static final DisplaySetting SHOW_PAGE = () -> 1; 9 | 10 | /** 11 | * Total pages available to display. 12 | */ 13 | public static final DisplaySetting TOTAL_PAGE = () -> 1; 14 | 15 | /** 16 | * The max number of lines per page. This excludes header. 17 | */ 18 | public static final DisplaySetting LINES_PER_PAGE = () -> 8; 19 | 20 | /** 21 | * Should add empty lines if content lines shown is less that {@link #LINES_PER_PAGE}. 22 | */ 23 | public static final DisplaySetting DO_END_PADDING = () -> true; 24 | 25 | /** 26 | * Should display with paging when it's sent to console. 27 | */ 28 | public static final DisplaySetting PAGE_IN_CONSOLE = () -> false; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /.github/workflows/dispatch.platform_uploads.yml: -------------------------------------------------------------------------------- 1 | name: 'Dispatch: Platform Uploads' 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | target_tag: 7 | description: 'Version to upload' 8 | required: true 9 | type: string 10 | upload_modrinth: 11 | description: 'Upload to modrinth.com' 12 | required: true 13 | type: boolean 14 | upload_dbo: 15 | description: 'Upload to dev.bukkit.org' 16 | required: true 17 | type: boolean 18 | upload_hangar: 19 | description: 'Upload to hangar.papermc.io' 20 | required: true 21 | type: boolean 22 | 23 | jobs: 24 | dispatch_platform_uploads: 25 | uses: ./.github/workflows/call.platform_uploads.yml 26 | secrets: inherit 27 | with: 28 | target_tag: ${{ github.event.inputs.target_tag }} 29 | upload_modrinth: ${{ github.event.inputs.upload_modrinth }} 30 | upload_dbo: ${{ github.event.inputs.upload_dbo }} 31 | upload_hangar: ${{ github.event.inputs.upload_hangar }} 32 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/enums/Action.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.enums; 9 | 10 | /** 11 | * A enum containing all actions that can be used to modify world-properties. 12 | */ 13 | public enum Action { 14 | /** 15 | * Setting a property. 16 | */ 17 | Set, 18 | /** 19 | * Adding something to a list-property. 20 | */ 21 | Add, 22 | /** 23 | * Removing something from a list-property. 24 | */ 25 | Remove, 26 | /** 27 | * Clearing a list-property. 28 | */ 29 | Clear 30 | } 31 | -------------------------------------------------------------------------------- /.github/workflows/call.github_release.yml: -------------------------------------------------------------------------------- 1 | name: 'Call: GitHub Release' 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | release_mode: 7 | description: 'Release mode' 8 | required: true 9 | type: string 10 | version_bump: 11 | description: 'Version bump' 12 | required: false 13 | type: string 14 | promote_from: 15 | description: 'Promote from' 16 | required: false 17 | type: string 18 | outputs: 19 | release_created: 20 | description: 'Release created' 21 | value: ${{ jobs.github_release.outputs.release_created }} 22 | tag_name: 23 | description: 'Tag name' 24 | value: ${{ jobs.github_release.outputs.tag_name }} 25 | 26 | jobs: 27 | github_release: 28 | uses: ./.github/workflows/generic.github_release.yml 29 | secrets: inherit 30 | with: 31 | plugin_name: multiverse-core 32 | release_mode: ${{ inputs.release_mode }} 33 | version_bump: ${{ inputs.version_bump }} 34 | promote_from: ${{ inputs.promote_from }} 35 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/display/handlers/ListDisplayHandler.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.display.handlers; 2 | 3 | import com.onarandombox.MultiverseCore.display.ContentDisplay; 4 | import com.onarandombox.MultiverseCore.display.DisplayFormatException; 5 | import com.onarandombox.MultiverseCore.display.DisplayHandler; 6 | import org.bukkit.command.CommandSender; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import java.util.Collection; 10 | import java.util.stream.Collectors; 11 | 12 | public class ListDisplayHandler implements DisplayHandler> { 13 | 14 | @Override 15 | public Collection format(@NotNull CommandSender sender, @NotNull ContentDisplay> display) 16 | throws DisplayFormatException { 17 | return display.getContents().stream() 18 | .filter(display.getFilter()::checkMatch) 19 | .map(s -> (ContentDisplay.LINE_BREAK.equals(s)) ? "" : display.getColorTool().get() + s) 20 | .collect(Collectors.toList()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/PaginatedCoreCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | 12 | /** 13 | * A generic paginated Multiverse-command. 14 | * @param The type of items on the page. 15 | */ 16 | public abstract class PaginatedCoreCommand extends PaginatedCommand { 17 | /** 18 | * The reference to the core. 19 | */ 20 | protected MultiverseCore plugin; 21 | 22 | public PaginatedCoreCommand(MultiverseCore plugin) { 23 | super(plugin); 24 | this.plugin = plugin; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/event/MVDebugModeEvent.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.event; 2 | 3 | import org.bukkit.event.Event; 4 | import org.bukkit.event.HandlerList; 5 | 6 | /** 7 | * Called when Core's debug level is changed. 8 | */ 9 | public class MVDebugModeEvent extends Event { 10 | 11 | private static final HandlerList HANDLERS = new HandlerList(); 12 | 13 | private final int level; 14 | 15 | public MVDebugModeEvent(int level) { 16 | this.level = level; 17 | } 18 | 19 | /** 20 | * {@inheritDoc} 21 | */ 22 | @Override 23 | public HandlerList getHandlers() { 24 | return HANDLERS; 25 | } 26 | 27 | /** 28 | * Gets the handler list. This is required by the event system. 29 | * @return A list of HANDLERS. 30 | */ 31 | public static HandlerList getHandlerList() { 32 | return HANDLERS; 33 | } 34 | 35 | /** 36 | * Returns the current debug level of Core. 37 | * 38 | * @return the current debug level of Core. 39 | */ 40 | public int getLevel() { 41 | return level; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/PasteServiceFactory.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils.webpaste; 2 | 3 | /** 4 | * Used to construct {@link PasteService}s. 5 | */ 6 | public class PasteServiceFactory { 7 | private PasteServiceFactory() { } 8 | 9 | /** 10 | * Constructs a new {@link PasteService}. 11 | * @param type The {@link PasteServiceType}. 12 | * @param isPrivate Whether the new {@link PasteService} should create private pastes. 13 | * @return The newly created {@link PasteService}. 14 | */ 15 | public static PasteService getService(PasteServiceType type, boolean isPrivate) { 16 | switch(type) { 17 | case PASTEGG: 18 | return new PasteGGPasteService(isPrivate); 19 | case PASTEBIN: 20 | return new PastebinPasteService(isPrivate); 21 | case HASTEBIN: 22 | return new HastebinPasteService(); 23 | case GITHUB: 24 | return new GitHubPasteService(isPrivate); 25 | default: 26 | return null; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/configuration/WorldPropertyValidator.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.configuration; 2 | 3 | import org.bukkit.Bukkit; 4 | 5 | import com.onarandombox.MultiverseCore.MVWorld; 6 | import com.onarandombox.MultiverseCore.event.MVWorldPropertyChangeEvent; 7 | 8 | import me.main__.util.SerializationConfig.ChangeDeniedException; 9 | import me.main__.util.SerializationConfig.ObjectUsingValidator; 10 | 11 | /** 12 | * Validates world-property-changes. 13 | * @param The type of the property that should be validated. 14 | */ 15 | public class WorldPropertyValidator extends ObjectUsingValidator { 16 | /** 17 | * {@inheritDoc} 18 | */ 19 | @Override 20 | public T validateChange(String property, T newValue, T oldValue, MVWorld object) throws ChangeDeniedException { 21 | MVWorldPropertyChangeEvent event = new MVWorldPropertyChangeEvent(object, null, property, newValue); 22 | Bukkit.getPluginManager().callEvent(event); 23 | if (event.isCancelled()) 24 | throw new ChangeDeniedException(); 25 | return event.getTheNewValue(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.github/workflows/dispatch.promote_release.yml: -------------------------------------------------------------------------------- 1 | name: 'Dispatch: Promote Release' 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | target_tag: 7 | description: 'Version to promote' 8 | required: true 9 | 10 | jobs: 11 | check_version: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Verify input version is prerelease 15 | run: | 16 | if [[ "${{ github.event.inputs.target_tag }}" != *"pre"* ]]; then 17 | echo "Version must be a prerelease" 18 | exit 1 19 | fi 20 | 21 | github_release: 22 | needs: check_version 23 | uses: ./.github/workflows/call.github_release.yml 24 | secrets: inherit 25 | with: 26 | release_mode: promote 27 | promote_from: ${{ github.event.inputs.target_tag }} 28 | 29 | platform_uploads: 30 | needs: github_release 31 | if: needs.github_release.outputs.release_created == 'true' 32 | uses: ./.github/workflows/call.platform_uploads.yml 33 | secrets: inherit 34 | with: 35 | target_tag: ${{ needs.github_release.outputs.tag_name }} 36 | upload_modrinth: 'true' 37 | upload_dbo: 'true' 38 | upload_hangar: 'true' 39 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/MVTravelAgent.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.utils; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import com.onarandombox.MultiverseCore.api.MVDestination; 12 | import org.bukkit.entity.Player; 13 | 14 | /** 15 | * The Multiverse TravelAgent. 16 | */ 17 | public class MVTravelAgent { 18 | protected MVDestination destination; 19 | protected MultiverseCore core; 20 | protected Player player; 21 | 22 | public MVTravelAgent(MultiverseCore multiverseCore, MVDestination d, Player p) { 23 | this.destination = d; 24 | this.core = multiverseCore; 25 | this.player = p; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/enums/TeleportResult.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.enums; 9 | 10 | /** 11 | * An enum containing possible teleport-results. 12 | */ 13 | public enum TeleportResult { 14 | /** 15 | * Insufficient permissions. 16 | */ 17 | FAIL_PERMISSION, 18 | /** 19 | * The teleport was unsafe. 20 | */ 21 | FAIL_UNSAFE, 22 | /** 23 | * The player was to poor. 24 | */ 25 | FAIL_TOO_POOR, 26 | /** 27 | * The teleport was invalid. 28 | */ 29 | FAIL_INVALID, 30 | /** 31 | * Unknown reason. 32 | */ 33 | FAIL_OTHER, 34 | /** 35 | * The player was successfully teleported. 36 | */ 37 | SUCCESS 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/metrics/MetricsHelper.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils.metrics; 2 | 3 | import org.bstats.charts.AdvancedPie; 4 | import org.bstats.charts.MultiLineChart; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | import java.util.function.Consumer; 9 | 10 | enum MetricsHelper { 11 | ; 12 | 13 | /** 14 | * Adds one to the value in the given map with the given key. If the key does not exist in the map, it will be added with a value of 1. 15 | */ 16 | static void incrementCount(Map map, String key) { 17 | Integer count = map.getOrDefault(key, 0); 18 | map.put(key, count + 1); 19 | } 20 | 21 | static AdvancedPie createAdvancedPieChart(String chartId, Consumer> metricsFunc) { 22 | Map map = new HashMap<>(); 23 | metricsFunc.accept(map); 24 | return new AdvancedPie(chartId, () -> map); 25 | } 26 | 27 | static MultiLineChart createMultiLineChart(String chartId, Consumer> metricsFunc) { 28 | Map map = new HashMap<>(); 29 | metricsFunc.accept(map); 30 | return new MultiLineChart(chartId, () -> map); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/api/LoggablePlugin.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.api; 9 | 10 | import com.dumptruckman.minecraft.util.Logging; 11 | import org.bukkit.Server; 12 | 13 | import java.util.logging.Level; 14 | 15 | /** 16 | * A simple API to require plugins to have a log method. 17 | * 18 | * @deprecated Replaced by {@link Logging}. 19 | * */ 20 | @Deprecated 21 | public interface LoggablePlugin { 22 | /** 23 | * Logs a message at the specified level. 24 | * 25 | * @param level The Log-{@link Level}. 26 | * @param msg The message to log. 27 | */ 28 | void log(Level level, String msg); 29 | 30 | /** 31 | * Gets the server instance that this plugin is attached to. 32 | * 33 | * @return A {@link Server} instance. 34 | */ 35 | Server getServer(); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/configuration/SpawnSettings.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.configuration; 2 | 3 | import java.util.Map; 4 | 5 | import me.main__.util.SerializationConfig.Property; 6 | import me.main__.util.SerializationConfig.SerializationConfig; 7 | 8 | import org.bukkit.configuration.serialization.SerializableAs; 9 | 10 | /** 11 | * Spawning-Settings. 12 | */ 13 | @SerializableAs("MVSpawnSettings") 14 | public class SpawnSettings extends SerializationConfig { 15 | @Property 16 | private SubSpawnSettings animals; 17 | @Property 18 | private SubSpawnSettings monsters; 19 | 20 | public SpawnSettings() { 21 | super(); 22 | } 23 | 24 | public SpawnSettings(Map values) { 25 | super(values); 26 | } 27 | 28 | /** 29 | * {@inheritDoc} 30 | */ 31 | @Override 32 | public void setDefaults() { 33 | animals = new SubSpawnSettings(); 34 | monsters = new SubSpawnSettings(); 35 | } 36 | 37 | /** 38 | * @return the animal-settings 39 | */ 40 | public SubSpawnSettings getAnimalSettings() { 41 | return animals; 42 | } 43 | 44 | /** 45 | * @return the monster-settings 46 | */ 47 | public SubSpawnSettings getMonsterSettings() { 48 | return monsters; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/resources/defaults/config.yml: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------- # 2 | # This is the MV2 Config. If you mess it up, copy the values out # 3 | # delete it, and it will be regenerated. Then use the ingame interface # 4 | # to add your values back via the "/mv conf" command. # 5 | # When in-game, simply type: "/mv conf ?" for help. # 6 | # A config with explanations can be found here: # 7 | # https://github.com/Multiverse/Multiverse-Core/wiki/config.yml # 8 | # # 9 | # # 10 | # IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !!IMPORTANT # 11 | # # 12 | # Do NOT delete this line from your config!!!! # 13 | # ==: com.onarandombox.MultiverseCore.MultiverseCoreConfiguration # 14 | # # 15 | # IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !!IMPORTANT # 16 | # ------------------------------------------------------------------------- # 17 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/listeners/MVWorldInitListener.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.listeners; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import org.bukkit.event.EventHandler; 12 | import org.bukkit.event.Listener; 13 | import org.bukkit.event.world.WorldInitEvent; 14 | 15 | public class MVWorldInitListener implements Listener { 16 | 17 | MultiverseCore plugin; 18 | 19 | public MVWorldInitListener(MultiverseCore plugin) { 20 | this.plugin = plugin; 21 | } 22 | 23 | @EventHandler 24 | public void initWorld(WorldInitEvent event) { 25 | plugin.getMorePaperLib().scheduling().globalRegionalScheduler().run(() -> { 26 | if (!plugin.getMVWorldManager().isKeepingSpawnInMemory(event.getWorld())) { 27 | event.getWorld().setKeepSpawnInMemory(false); 28 | } 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /.github/workflows/generic.test.yml: -------------------------------------------------------------------------------- 1 | name: 'Generic: Test' 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | plugin_name: 7 | description: 'Plugin name' 8 | required: true 9 | type: string 10 | 11 | jobs: 12 | test-and-artifact: 13 | runs-on: ubuntu-latest 14 | permissions: 15 | contents: read 16 | steps: 17 | - uses: actions/checkout@v4 18 | 19 | - uses: actions/setup-java@v4 20 | with: 21 | java-version: '11' 22 | distribution: 'adopt' 23 | cache: gradle 24 | 25 | - name: Setup Gradle 26 | uses: gradle/actions/setup-gradle@v4 27 | 28 | - name: Run unit tests 29 | run: ./gradlew build 30 | env: 31 | GITHUB_VERSION: pr${{ github.event.pull_request.number }} 32 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 33 | 34 | - name: Artifact output 35 | uses: actions/upload-artifact@v4 36 | with: 37 | name: ${{ inputs.plugin_name }}-pr${{ github.event.pull_request.number }} 38 | path: build/libs/${{ inputs.plugin_name }}-pr${{ github.event.pull_request.number }}.jar 39 | 40 | comment-artifact: 41 | needs: test-and-artifact 42 | runs-on: ubuntu-latest 43 | permissions: 44 | pull-requests: write 45 | steps: 46 | - uses: benwoo1110/artifact-comment-action@v1 47 | with: 48 | github_token: ${{ secrets.GITHUB_TOKEN }} 49 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/FancyHeader.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.utils; 9 | 10 | import com.onarandombox.MultiverseCore.api.FancyText; 11 | 12 | /** 13 | * A colored text-header. 14 | */ 15 | public class FancyHeader implements FancyText { 16 | 17 | private FancyColorScheme colors; 18 | private StringBuilder text; 19 | 20 | public FancyHeader(String text, FancyColorScheme scheme) { 21 | this.colors = scheme; 22 | this.text = new StringBuilder(text); 23 | } 24 | 25 | @Override 26 | public String getFancyText() { 27 | return String.format("%s--- %s%s ---", colors.getHeader(), text.toString(), colors.getHeader()); 28 | } 29 | 30 | /** 31 | * Appends text to this {@link FancyHeader}. 32 | * @param string The text to append. 33 | */ 34 | public void appendText(String string) { 35 | this.text.append(string); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, The Multiverse Team All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 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. 6 | 7 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/enums/EnglishChatStyle.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.enums; 2 | 3 | import org.bukkit.ChatColor; 4 | 5 | /** 6 | * A regular {@link ChatColor} represented by an english string. 7 | * @see ChatColor 8 | */ 9 | public enum EnglishChatStyle { 10 | // BEGIN CHECKSTYLE-SUPPRESSION: JavadocVariable 11 | /** No style. */ 12 | NORMAL(null), 13 | MAGIC(ChatColor.MAGIC), 14 | BOLD(ChatColor.BOLD), 15 | STRIKETHROUGH(ChatColor.STRIKETHROUGH), 16 | UNDERLINE(ChatColor.UNDERLINE), 17 | ITALIC(ChatColor.ITALIC); 18 | // END CHECKSTYLE-SUPPRESSION: JavadocVariable 19 | 20 | private final ChatColor color; 21 | 22 | EnglishChatStyle(ChatColor color) { 23 | this.color = color; 24 | } 25 | 26 | /** 27 | * Gets the color. 28 | * @return The color as {@link ChatColor}. 29 | */ 30 | public ChatColor getColor() { 31 | return color; 32 | } 33 | 34 | /** 35 | * Constructs an {@link EnglishChatStyle} from a {@link String}. 36 | * @param text The {@link String}. 37 | * @return The {@link EnglishChatStyle}. 38 | */ 39 | public static EnglishChatStyle fromString(String text) { 40 | if (text != null) { 41 | for (EnglishChatStyle c : EnglishChatStyle.values()) { 42 | if (text.equalsIgnoreCase(c.name())) { 43 | return c; 44 | } 45 | } 46 | } 47 | return null; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/MultiverseCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import com.onarandombox.MultiverseCore.api.MultiverseMessaging; 12 | import com.pneumaticraft.commandhandler.Command; 13 | import org.bukkit.command.CommandSender; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * A generic Multiverse-command. 19 | */ 20 | public abstract class MultiverseCommand extends Command { 21 | 22 | /** 23 | * The reference to the core. 24 | */ 25 | protected MultiverseCore plugin; 26 | /** 27 | * The reference to {@link MultiverseMessaging}. 28 | */ 29 | protected MultiverseMessaging messaging; 30 | 31 | public MultiverseCommand(MultiverseCore plugin) { 32 | super(plugin); 33 | this.plugin = plugin; 34 | this.messaging = this.plugin.getMessaging(); 35 | } 36 | 37 | @Override 38 | public abstract void runCommand(CommandSender sender, List args); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/listeners/MVAsyncPlayerChatListener.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.listeners; 9 | 10 | import java.util.logging.Level; 11 | 12 | import com.dumptruckman.minecraft.util.Logging; 13 | import org.bukkit.event.EventHandler; 14 | import org.bukkit.event.player.AsyncPlayerChatEvent; 15 | 16 | import com.onarandombox.MultiverseCore.MultiverseCore; 17 | 18 | /** 19 | * Multiverse's {@link org.bukkit.event.Listener} for players. 20 | */ 21 | public class MVAsyncPlayerChatListener extends MVChatListener { 22 | public MVAsyncPlayerChatListener(MultiverseCore plugin, MVPlayerListener playerListener) { 23 | super(plugin, playerListener); 24 | Logging.fine("Created AsyncPlayerChatEvent listener."); 25 | } 26 | 27 | /** 28 | * This method is called when a player wants to chat. 29 | * @param event The Event that was fired. 30 | */ 31 | @EventHandler 32 | public void playerChat(AsyncPlayerChatEvent event) { 33 | this.playerChat(new AsyncChatEvent(event)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/listeners/MVPlayerChatListener.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.listeners; 9 | 10 | import java.util.logging.Level; 11 | 12 | import com.dumptruckman.minecraft.util.Logging; 13 | import org.bukkit.event.EventHandler; 14 | import org.bukkit.event.player.PlayerChatEvent; 15 | 16 | import com.onarandombox.MultiverseCore.MultiverseCore; 17 | 18 | /** 19 | * Multiverse's {@link org.bukkit.event.Listener} for players. 20 | */ 21 | @SuppressWarnings("deprecation") // this exists only for downwards compatibility 22 | public class MVPlayerChatListener extends MVChatListener { 23 | public MVPlayerChatListener(MultiverseCore plugin, MVPlayerListener playerListener) { 24 | super(plugin, playerListener); 25 | Logging.fine("Registered PlayerChatEvent listener."); 26 | } 27 | 28 | /** 29 | * This method is called when a player wants to chat. 30 | * @param event The Event that was fired. 31 | */ 32 | @EventHandler 33 | public void playerChat(PlayerChatEvent event) { 34 | this.playerChat(new NormalChatEvent(event)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/enums/AllowedPortalType.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2012. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.enums; 9 | 10 | import org.bukkit.PortalType; 11 | 12 | /** 13 | * Custom enum that adds all/none for allowing portal creation. 14 | */ 15 | public enum AllowedPortalType { 16 | /** 17 | * No portals are allowed. 18 | */ 19 | NONE(PortalType.CUSTOM), 20 | /** 21 | * All portal types are allowed. 22 | */ 23 | ALL(PortalType.CUSTOM), 24 | /** 25 | * Only Nether style portals are allowed. 26 | */ 27 | NETHER(PortalType.NETHER), 28 | /** 29 | * Only Ender style portals are allowed. 30 | */ 31 | END(PortalType.ENDER); 32 | 33 | private PortalType type; 34 | 35 | AllowedPortalType(PortalType type) { 36 | this.type = type; 37 | } 38 | 39 | /** 40 | * Gets the text. 41 | * @return The text. 42 | */ 43 | public PortalType getActualPortalType() { 44 | return this.type; 45 | } 46 | 47 | public boolean isPortalAllowed(PortalType portalType) { 48 | return this != NONE && (getActualPortalType() == portalType || this == ALL); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/listeners/MVMapListener.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.listeners; 2 | 3 | import com.onarandombox.MultiverseCore.MultiverseCore; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.Location; 6 | import org.bukkit.Material; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.EventHandler; 9 | import org.bukkit.event.Listener; 10 | import org.bukkit.event.server.MapInitializeEvent; 11 | import org.bukkit.map.MapView; 12 | 13 | /** 14 | * A listener for bukkit map events. 15 | */ 16 | public class MVMapListener implements Listener { 17 | 18 | private final MultiverseCore plugin; 19 | 20 | public MVMapListener(final MultiverseCore plugin) { 21 | this.plugin = plugin; 22 | } 23 | 24 | /** 25 | * This method is called when a map is initialized. 26 | * @param event The event that was fired. 27 | */ 28 | @EventHandler 29 | public void mapInitialize(final MapInitializeEvent event) { 30 | for (final Player player : Bukkit.getOnlinePlayers()) { 31 | if ((player.getItemInHand().getType() == Material.MAP 32 | || player.getItemInHand().getType() == Material.FILLED_MAP) 33 | && player.getItemInHand().getDurability() == event.getMap().getId()) { 34 | final Location playerLoc = player.getLocation(); 35 | final MapView map = event.getMap(); 36 | map.setCenterX(playerLoc.getBlockX()); 37 | map.setCenterZ(playerLoc.getBlockZ()); 38 | map.setWorld(playerLoc.getWorld()); 39 | return; 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/SleepCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import org.bukkit.command.CommandSender; 12 | import org.bukkit.entity.Player; 13 | import org.bukkit.permissions.PermissionDefault; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * Takes the player to the latest bed he's slept in. 19 | */ 20 | public class SleepCommand extends MultiverseCommand { 21 | 22 | public SleepCommand(MultiverseCore plugin) { 23 | super(plugin); 24 | this.setName("Go to Sleep"); 25 | this.setCommandUsage("/mv sleep"); 26 | this.setArgRange(0, 0); 27 | this.addKey("mv sleep"); 28 | this.setPermission("multiverse.core.sleep", "Takes you the latest bed you've slept in (Currently BROKEN).", PermissionDefault.OP); 29 | } 30 | 31 | @Override 32 | public void runCommand(CommandSender sender, List args) { 33 | Player p = null; 34 | if (sender instanceof Player) { 35 | p = (Player) sender; 36 | } 37 | 38 | if (p == null) { 39 | return; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/display/handlers/InlineListDisplayHandler.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.display.handlers; 2 | 3 | import com.onarandombox.MultiverseCore.display.ContentDisplay; 4 | import com.onarandombox.MultiverseCore.display.DisplayFormatException; 5 | import com.onarandombox.MultiverseCore.display.DisplayHandler; 6 | import com.onarandombox.MultiverseCore.display.settings.InlineDisplaySettings; 7 | import org.bukkit.command.CommandSender; 8 | import org.jetbrains.annotations.NotNull; 9 | 10 | import java.util.Collection; 11 | import java.util.Collections; 12 | import java.util.Iterator; 13 | 14 | public class InlineListDisplayHandler implements DisplayHandler> { 15 | 16 | @Override 17 | public Collection format(@NotNull CommandSender sender, @NotNull ContentDisplay> display) 18 | throws DisplayFormatException { 19 | StringBuilder builder = new StringBuilder(); 20 | String separator = display.getSetting(InlineDisplaySettings.SEPARATOR); 21 | 22 | for (Iterator iterator = display.getContents().iterator(); iterator.hasNext(); ) { 23 | String content = iterator.next(); 24 | if (!display.getFilter().checkMatch(content)) { 25 | continue; 26 | } 27 | builder.append(display.getColorTool().get()).append(content); 28 | if (iterator.hasNext()) { 29 | builder.append(separator); 30 | } 31 | } 32 | return (builder.length() == 0) 33 | ? Collections.singletonList(display.getEmptyMessage()) 34 | : Collections.singleton(builder.toString()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/MaterialConverter.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils; 2 | 3 | import de.themoep.idconverter.IdMappings; 4 | import org.bukkit.Material; 5 | import org.bukkit.configuration.ConfigurationSection; 6 | import org.jetbrains.annotations.NotNull; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | /** 10 | * A tool for converting values which may be an old type ID to a Material. 11 | */ 12 | public class MaterialConverter { 13 | 14 | /** 15 | * Converts the value in the given config at the given path from a numeric id or flattened material name to a 16 | * Material. 17 | * 18 | * @param config The config with the value to convert. 19 | * @param path The path of the value in the config. 20 | * @return The converted Material type or null if no matching type. 21 | */ 22 | @Nullable 23 | public static Material convertConfigType(@NotNull ConfigurationSection config, @NotNull String path) { 24 | return convertTypeString(config.getString(path)); 25 | } 26 | 27 | /** 28 | * Converts a string representing a numeric id or flattened material name to a Material. 29 | * 30 | * @param value The value to convert. 31 | * @return The converted Material type or null if no matching type. 32 | */ 33 | @Nullable 34 | public static Material convertTypeString(@Nullable String value) { 35 | IdMappings.Mapping mapping = IdMappings.getById(value != null ? value : ""); 36 | if (mapping != null) { 37 | return Material.matchMaterial(mapping.getFlatteningType()); 38 | } else { 39 | return Material.matchMaterial(value != null ? value : ""); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/ConfirmCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import org.bukkit.command.CommandSender; 12 | import org.bukkit.permissions.PermissionDefault; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * Confirms actions. 18 | */ 19 | public class ConfirmCommand extends MultiverseCommand { 20 | 21 | public ConfirmCommand(MultiverseCore plugin) { 22 | super(plugin); 23 | // Any command that is dangerous should require op 24 | this.setName("Confirms a command that could destroy life, the universe and everything."); 25 | this.setCommandUsage("/mv confirm"); 26 | this.setArgRange(0, 0); 27 | this.addKey("mvconfirm"); 28 | this.addKey("mv confirm"); 29 | this.addCommandExample("/mv confirm"); 30 | this.setPermission("multiverse.core.confirm", "If you have not been prompted to use this, it will not do anything.", PermissionDefault.OP); 31 | 32 | } 33 | 34 | @Override 35 | public void runCommand(CommandSender sender, List args) { 36 | this.plugin.getCommandQueueManager().runQueuedCommand(sender); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/TeleportUtil.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils; 2 | 3 | import com.onarandombox.MultiverseCore.MultiverseCore; 4 | import org.bukkit.Location; 5 | import org.bukkit.entity.Entity; 6 | import org.bukkit.entity.Player; 7 | 8 | import java.lang.reflect.InvocationTargetException; 9 | import java.lang.reflect.Method; 10 | import java.util.concurrent.CompletableFuture; 11 | 12 | public class TeleportUtil { 13 | 14 | private final MultiverseCore plugin; 15 | private final boolean isFolia; 16 | private Method teleportAsync; 17 | 18 | public TeleportUtil(MultiverseCore plugin){ 19 | this.plugin = plugin; 20 | this.isFolia = plugin.getMorePaperLib().scheduling().isUsingFolia(); 21 | if (isFolia) { 22 | try { 23 | teleportAsync = Entity.class.getMethod("teleportAsync", Location.class); 24 | } catch (NoSuchMethodException e) { 25 | throw new RuntimeException(e); 26 | } 27 | } 28 | } 29 | 30 | 31 | public CompletableFuture teleport(Entity entity, Location location) { 32 | 33 | if (!isFolia) { 34 | CompletableFuture result = new CompletableFuture<>(); 35 | result.complete(entity.teleport(location)); 36 | return result; 37 | } 38 | 39 | try { 40 | @SuppressWarnings("unchecked") 41 | CompletableFuture result = (CompletableFuture) teleportAsync.invoke(entity, location); 42 | return result; 43 | } catch (IllegalAccessException | InvocationTargetException e) { 44 | throw new RuntimeException(e); 45 | } 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/BitlyURLShortener.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils.webpaste; 2 | 3 | import org.json.simple.JSONObject; 4 | import org.json.simple.parser.JSONParser; 5 | import org.json.simple.parser.ParseException; 6 | 7 | import java.io.IOException; 8 | import java.util.Map; 9 | 10 | /** 11 | * A {@link URLShortener} using {@code bit.ly}. Requires an access token. 12 | */ 13 | class BitlyURLShortener extends URLShortener { 14 | private static final String ACCESS_TOKEN = "Bearer @bitly-access-token@"; 15 | private static final String BITLY_POST_REQUEST = "https://api-ssl.bitly.com/v4/shorten"; 16 | 17 | BitlyURLShortener() { 18 | super(BITLY_POST_REQUEST, ACCESS_TOKEN); 19 | if (ACCESS_TOKEN.endsWith("access-token")) { 20 | throw new UnsupportedOperationException(); 21 | } 22 | } 23 | 24 | /** 25 | * {@inheritDoc} 26 | */ 27 | @Override 28 | String encodeData(String data) { 29 | JSONObject json = new JSONObject(); 30 | json.put("long_url", data); 31 | return json.toJSONString(); 32 | } 33 | 34 | /** 35 | * {@inheritDoc} 36 | */ 37 | @Override 38 | String encodeData(Map data) { 39 | throw new UnsupportedOperationException(); 40 | } 41 | 42 | /** 43 | * {@inheritDoc} 44 | */ 45 | @Override 46 | public String shorten(String longUrl) { 47 | try { 48 | String stringJSON = this.exec(encodeData(longUrl), ContentType.JSON); 49 | return (String) ((JSONObject) new JSONParser().parse(stringJSON)).get("link"); 50 | } catch (IOException | ParseException e) { 51 | e.printStackTrace(); 52 | return longUrl; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /.github/workflows/dispatch.javadoc.yml: -------------------------------------------------------------------------------- 1 | name: 'Dispatch: Deploy Javadoc' 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | target_tag: 7 | description: 'Version to generate javadoc' 8 | required: true 9 | replace_latest: 10 | description: 'Replace the latest folder' 11 | type: boolean 12 | 13 | jobs: 14 | javadocs: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v4 18 | with: 19 | ref: ${{ inputs.target_tag }} 20 | 21 | - uses: actions/setup-java@v4 22 | with: 23 | java-version: '11' 24 | distribution: 'adopt' 25 | cache: gradle 26 | 27 | - name: Setup Gradle 28 | uses: gradle/actions/setup-gradle@v4 29 | 30 | - name: build javadoc 31 | run: ./gradlew javadoc 32 | env: 33 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 34 | GITHUB_VERSION: ${{ inputs.target_tag }} 35 | 36 | - name: Copy javadoc to deploy folder 37 | run: | 38 | mkdir -p build/docs/javadoc-deploy/${{ inputs.target_tag }} 39 | cp -r build/docs/javadoc/* build/docs/javadoc-deploy/${{ inputs.target_tag }} 40 | 41 | - name: Copy javadoc to latest folder 42 | if: inputs.replace_latest 43 | run: | 44 | mkdir -p build/docs/javadoc-deploy/latest 45 | cp -r build/docs/javadoc/* build/docs/javadoc-deploy/latest 46 | 47 | - name: Deploy javadoc to gh pages 48 | uses: JamesIves/github-pages-deploy-action@v4 49 | with: 50 | token: ${{ secrets.GITHUB_TOKEN }} 51 | folder: build/docs/javadoc-deploy 52 | branch: javadoc 53 | target-folder: javadoc 54 | clean: false 55 | commit-message: Deploy javadoc for ${{ inputs.target_tag }} 56 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/configuration/SubSpawnSettings.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.configuration; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import me.main__.util.SerializationConfig.Property; 8 | import me.main__.util.SerializationConfig.SerializationConfig; 9 | 10 | import org.bukkit.configuration.serialization.SerializableAs; 11 | 12 | /** 13 | * SpawnSubSettings. 14 | */ 15 | @SerializableAs("MVSpawnSubSettings") 16 | public class SubSpawnSettings extends SerializationConfig { 17 | @Property 18 | private boolean spawn; 19 | @Property 20 | private int spawnrate; 21 | @Property 22 | private List exceptions; 23 | 24 | public SubSpawnSettings() { 25 | super(); 26 | } 27 | 28 | public SubSpawnSettings(Map values) { 29 | super(values); 30 | } 31 | 32 | /** 33 | * {@inheritDoc} 34 | */ 35 | @Override 36 | public void setDefaults() { 37 | spawn = true; 38 | exceptions = new ArrayList(); 39 | spawnrate = -1; 40 | } 41 | 42 | /** 43 | * @return spawn 44 | */ 45 | public boolean doSpawn() { 46 | return spawn; 47 | } 48 | 49 | /** 50 | * @param spawn The new value. 51 | */ 52 | public void setSpawn(boolean spawn) { 53 | this.spawn = spawn; 54 | } 55 | 56 | /** 57 | * @return The exceptions 58 | */ 59 | public List getExceptions() { 60 | return exceptions; 61 | } 62 | 63 | /** 64 | * @param rate The new spawn rate 65 | */ 66 | public void setSpawnRate(int rate) { 67 | this.spawnrate = rate; 68 | } 69 | 70 | /** 71 | * @return The spawn rate 72 | */ 73 | public int getSpawnRate() { 74 | return this.spawnrate; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/display/ColorAlternator.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.display; 2 | 3 | import org.bukkit.ChatColor; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | /** 7 | * Helper class to switch between 2 {@link ChatColor}. 8 | */ 9 | public class ColorAlternator implements ColorTool { 10 | 11 | /** 12 | * Creates a new {@link ColorAlternator} with 2 {@link ChatColor}s. 13 | * 14 | * @param colorThis The first color. 15 | * @param colorThat The second color. 16 | * @return The {@link ColorAlternator} created for you. 17 | */ 18 | public static ColorAlternator with(@NotNull ChatColor colorThis, 19 | @NotNull ChatColor colorThat) { 20 | 21 | return new ColorAlternator(colorThis, colorThat); 22 | } 23 | 24 | private boolean switcher; 25 | private final ChatColor thisColor; 26 | private final ChatColor thatColor; 27 | 28 | /** 29 | * @param colorThis The first color. 30 | * @param colorThat The second color. 31 | */ 32 | public ColorAlternator(@NotNull ChatColor colorThis, 33 | @NotNull ChatColor colorThat) { 34 | 35 | this.thisColor = colorThis; 36 | this.thatColor = colorThat; 37 | } 38 | 39 | /** 40 | * Gets the color. Everytime this method is called, it swaps the color that it returns. 41 | * 42 | * @return The color. 43 | */ 44 | @Override 45 | public ChatColor get() { 46 | return (this.switcher ^= true) ? this.thisColor : this.thatColor; 47 | } 48 | 49 | /** 50 | * @return The first color. 51 | */ 52 | public ChatColor getThisColor() { 53 | return thisColor; 54 | } 55 | 56 | /** 57 | * @return The second color. 58 | */ 59 | public ChatColor getThatColor() { 60 | return thatColor; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/MVPlayerSession.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.utils; 9 | 10 | import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig; 11 | import org.bukkit.entity.Player; 12 | 13 | import java.util.Date; 14 | 15 | /** 16 | * A player-session. 17 | */ 18 | public class MVPlayerSession { 19 | 20 | private Player player; // Player holder, may be unnecessary. 21 | 22 | private long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation. 23 | private long messageLast = 0L; // Timestamp for the Players last Alert Message. 24 | 25 | private MultiverseCoreConfig config; // Configuration file to find out Cooldown Timers. 26 | 27 | public MVPlayerSession(Player player, MultiverseCoreConfig config) { 28 | this.player = player; 29 | this.config = config; 30 | // this.bedSpawn = null; 31 | } 32 | 33 | /** Update the Teleport time. */ 34 | public void teleport() { 35 | this.teleportLast = (new Date()).getTime(); 36 | } 37 | 38 | /** 39 | * Grab whether the cooldown on Portal use has expired or not. 40 | * @return True if the {@link Player} associated with this player-session is teleportable. 41 | */ 42 | public boolean getTeleportable() { 43 | long time = (new Date()).getTime(); 44 | return ((time - this.teleportLast) > this.config.getTeleportCooldown()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/UnsafeCallWrapper.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils; 2 | 3 | import com.dumptruckman.minecraft.util.Logging; 4 | import com.onarandombox.MultiverseCore.api.Core; 5 | 6 | import java.util.concurrent.Callable; 7 | 8 | /** 9 | * Wraps calls that could result in exceptions that are not Multiverse's fault. 10 | */ 11 | public class UnsafeCallWrapper { 12 | private final Core core; 13 | 14 | public UnsafeCallWrapper(Core core) { 15 | this.core = core; 16 | } 17 | 18 | /** 19 | * Wraps calls that could result in exceptions that are not Multiverse's fault. 20 | * 21 | * @param callable The potentially unsafe call. 22 | * @param plugin The plugin that's probably the culprit. 23 | * @param action What MV was attempting to do (error message, format string). 24 | * @param formatArgs The formatting arguments for the error message. 25 | * The exception that was thrown will be appended to these objects. 26 | * @param The type of the return value. 27 | * @return The return value or null if the call failed. 28 | */ 29 | public T wrap(Callable callable, String plugin, String action, Object... formatArgs) { 30 | try { 31 | // We're ready to catch you! JUMP! 32 | return callable.call(); 33 | } catch (Throwable t) { 34 | Object[] actualFormatArgs = new Object[formatArgs.length + 1]; 35 | System.arraycopy(formatArgs, 0, actualFormatArgs, 0, formatArgs.length); 36 | actualFormatArgs[formatArgs.length] = t; 37 | Logging.warning(action, actualFormatArgs); 38 | Logging.warning("This is a bug in %s, NOT a bug in Multiverse!", plugin); 39 | if (core.getMVConfig().getGlobalDebug() >= 1) 40 | t.printStackTrace(); 41 | return null; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/event/MVConfigReloadEvent.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.event; 9 | 10 | import org.bukkit.event.Event; 11 | import org.bukkit.event.HandlerList; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * Called when the Multiverse-config should be reloaded. 17 | */ 18 | public class MVConfigReloadEvent extends Event { 19 | private List configsLoaded; 20 | 21 | public MVConfigReloadEvent(List configsLoaded) { 22 | this.configsLoaded = configsLoaded; 23 | } 24 | 25 | private static final HandlerList HANDLERS = new HandlerList(); 26 | 27 | /** 28 | * {@inheritDoc} 29 | */ 30 | @Override 31 | public HandlerList getHandlers() { 32 | return HANDLERS; 33 | } 34 | 35 | /** 36 | * Gets the handler list. This is required by the event system. 37 | * @return A list of HANDLERS. 38 | */ 39 | public static HandlerList getHandlerList() { 40 | return HANDLERS; 41 | } 42 | 43 | /** 44 | * Adds a config to this event. 45 | * @param config The config to add. 46 | */ 47 | public void addConfig(String config) { 48 | this.configsLoaded.add(config); 49 | } 50 | 51 | /** 52 | * Gets all loaded configs. 53 | * @return A list of all loaded configs. 54 | */ 55 | public List getAllConfigsLoaded() { 56 | return this.configsLoaded; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/UnloadCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import org.bukkit.ChatColor; 12 | import org.bukkit.command.Command; 13 | import org.bukkit.command.CommandSender; 14 | import org.bukkit.permissions.PermissionDefault; 15 | 16 | import java.util.List; 17 | 18 | /** 19 | * Unloads worlds from Multiverse. 20 | */ 21 | public class UnloadCommand extends MultiverseCommand { 22 | 23 | public UnloadCommand(MultiverseCore plugin) { 24 | super(plugin); 25 | this.setName("Unload World"); 26 | this.setCommandUsage("/mv unload" + ChatColor.GREEN + " {WORLD}"); 27 | this.setArgRange(1, 1); 28 | this.addKey("mvunload"); 29 | this.addKey("mv unload"); 30 | this.setPermission("multiverse.core.unload", 31 | "Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file.", PermissionDefault.OP); 32 | } 33 | 34 | @Override 35 | public void runCommand(CommandSender sender, List args) { 36 | if (this.plugin.getMVWorldManager().unloadWorld(args.get(0))) { 37 | Command.broadcastCommandMessage(sender, "Unloaded world '" + args.get(0) + "'!"); 38 | } else { 39 | sender.sendMessage("Error trying to unload world '" + args.get(0) + "'!"); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/RemoveCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import org.bukkit.ChatColor; 12 | import org.bukkit.command.CommandSender; 13 | import org.bukkit.permissions.PermissionDefault; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * Unloads a world and removes it from the config. 19 | */ 20 | public class RemoveCommand extends MultiverseCommand { 21 | 22 | public RemoveCommand(MultiverseCore plugin) { 23 | super(plugin); 24 | this.setName("Remove World"); 25 | this.setCommandUsage("/mv remove" + ChatColor.GREEN + " {WORLD}"); 26 | this.setArgRange(1, 1); 27 | this.addKey("mvremove"); 28 | this.addKey("mv remove"); 29 | this.addCommandExample("/mv remove " + ChatColor.GREEN + "MyWorld"); 30 | this.setPermission("multiverse.core.remove", 31 | "Unloads a world from Multiverse and removes it from worlds.yml, this does NOT DELETE the world folder.", PermissionDefault.OP); 32 | } 33 | 34 | @Override 35 | public void runCommand(CommandSender sender, List args) { 36 | if (this.plugin.getMVWorldManager().removeWorldFromConfig(args.get(0))) { 37 | sender.sendMessage("World removed from config!"); 38 | } else { 39 | sender.sendMessage("Error trying to remove world from config!"); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yml: -------------------------------------------------------------------------------- 1 | name: 💡 Request a Feature 2 | description: Suggest a feature you want to see in Multiverse-Core! 3 | title: "[Idea]: " 4 | labels: ["Type: Idea"] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thanks for taking the time to share your ideas! 10 | 11 | If you are look for other submodules of Multiverse, go to their respective git repo: 12 | Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues/new/choose 13 | Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues/new/choose 14 | Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues/new/choose 15 | Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues/new/choose 16 | 17 | Not sure if your feature fits in Multiverse-Core? Feel free to ask on our Discord server: https://discord.gg/NZtfKky 18 | - type: textarea 19 | id: feature-description 20 | attributes: 21 | label: Describe the feature 22 | description: What feature are you suggesting? 23 | placeholder: "Example: I hope multiverse can implement random teleport feature..." 24 | validations: 25 | required: true 26 | - type: textarea 27 | id: feature-reasoning 28 | attributes: 29 | label: How is the feature useful to all Multiverse users? 30 | description: How is the feature useful to all players, server owners and/or developers? 31 | placeholder: "Example: Random teleporting can be integrated into many multiverse modules such as mv-portals..." 32 | validations: 33 | required: true 34 | - type: checkboxes 35 | id: agreements 36 | attributes: 37 | label: Agreements 38 | description: Ensure you have done the following being submitting this issue. 39 | options: 40 | - label: I have searched for and ensured there isn't already an open issue regarding this. 41 | required: true 42 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/display/DisplayHandlers.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.display; 2 | 3 | import com.onarandombox.MultiverseCore.display.handlers.InlineListDisplayHandler; 4 | import com.onarandombox.MultiverseCore.display.handlers.InlineMapDisplayHandler; 5 | import com.onarandombox.MultiverseCore.display.handlers.ListDisplayHandler; 6 | import com.onarandombox.MultiverseCore.display.handlers.PagedListDisplayHandler; 7 | import com.onarandombox.MultiverseCore.display.settings.InlineDisplaySettings; 8 | import com.onarandombox.MultiverseCore.display.settings.PagedDisplaySettings; 9 | import com.onarandombox.MultiverseCore.display.settings.MapDisplaySettings; 10 | 11 | import java.util.Collection; 12 | import java.util.Map; 13 | 14 | /** 15 | * Various implementations of {@link DisplayHandler}. 16 | */ 17 | public class DisplayHandlers { 18 | 19 | /** 20 | * Standard list display. 21 | * 22 | * Supported settings: none. 23 | */ 24 | public static final DisplayHandler> LIST = new ListDisplayHandler(); 25 | 26 | /** 27 | * List display with paging. 28 | * 29 | * Supported settings: {@link PagedDisplaySettings#SHOW_PAGE}, {@link PagedDisplaySettings#LINES_PER_PAGE}, 30 | * {@link PagedDisplaySettings#PAGE_IN_CONSOLE}, {@link PagedDisplaySettings#DO_END_PADDING}. 31 | */ 32 | public static final DisplayHandler> PAGE_LIST = new PagedListDisplayHandler(); 33 | 34 | /** 35 | * Display a list inline. 36 | * 37 | * Supported settings: {@link InlineDisplaySettings#SEPARATOR}. 38 | */ 39 | public static final DisplayHandler> INLINE_LIST = new InlineListDisplayHandler(); 40 | 41 | /** 42 | * Display key value pair inline. 43 | * 44 | * Supported settings: {@link InlineDisplaySettings#SEPARATOR}, {@link MapDisplaySettings#OPERATOR}. 45 | */ 46 | public static final DisplayHandler> INLINE_MAP = new InlineMapDisplayHandler(); 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/LoadCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import org.bukkit.ChatColor; 12 | import org.bukkit.command.Command; 13 | import org.bukkit.command.CommandSender; 14 | import org.bukkit.permissions.PermissionDefault; 15 | 16 | import java.util.List; 17 | 18 | /** 19 | * Loads a world into Multiverse. 20 | */ 21 | public class LoadCommand extends MultiverseCommand { 22 | 23 | public LoadCommand(MultiverseCore plugin) { 24 | super(plugin); 25 | this.setName("Load World"); 26 | this.setCommandUsage("/mv load" + ChatColor.GREEN + " {WORLD}"); 27 | this.setArgRange(1, 1); 28 | this.addKey("mvload"); 29 | this.addKey("mv load"); 30 | this.addCommandExample("/mv load " + ChatColor.GREEN + "MyUnloadedWorld"); 31 | this.setPermission("multiverse.core.load", "Loads a world into Multiverse.", PermissionDefault.OP); 32 | } 33 | 34 | @Override 35 | public void runCommand(CommandSender sender, List args) { 36 | plugin.getMorePaperLib().scheduling().globalRegionalScheduler().run(() -> { 37 | if (this.plugin.getMVWorldManager().loadWorld(args.get(0))) { 38 | Command.broadcastCommandMessage(sender, "Loaded world '" + args.get(0) + "'!"); 39 | } else { 40 | sender.sendMessage("Error trying to load world '" + args.get(0) + "'!"); 41 | } 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/PasteService.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils.webpaste; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * An interface to a web-based text-pasting service. Classes extending this 7 | * should implement its methods to send data to an online text-sharing service, 8 | * such as pastebin.com. Given some PasteService instance ps, a paste is accomplished by: 9 | * 10 | * {@code ps.postData(someString);} 11 | * 12 | * Services that provide a distinction between "public" and "private" pastes 13 | * should implement a constructor that specifies which kind the PasteService 14 | * instance is submitting; an example of this is the PastebinPasteService class. 15 | */ 16 | public abstract class PasteService extends HttpAPIClient { 17 | PasteService(String url) { 18 | super(url); 19 | } 20 | 21 | PasteService(String url, String accessToken) { 22 | super(url, accessToken); 23 | } 24 | 25 | /** 26 | * Post data to the Web. 27 | * 28 | * @param data A String to post to the web. 29 | * @throws PasteFailedException When pasting/posting the data failed. 30 | * @return The URL at which the new paste is visible. 31 | */ 32 | public abstract String postData(String data) throws PasteFailedException; 33 | 34 | /** 35 | * Post data to the Web. 36 | * 37 | * @param data A Map to post to the web. 38 | * @throws PasteFailedException When pasting/posting the data failed. 39 | * @return The URL at which the new paste is visible. 40 | */ 41 | public abstract String postData(Map data) throws PasteFailedException; 42 | 43 | /** 44 | * Does this service support uploading multiple files. 45 | * 46 | * Newer services like GitHub's Gist support multi-file pastes, 47 | * which allows us to upload configs in addition to the standard logs. 48 | * 49 | * @return True if this service supports multiple file upload. 50 | */ 51 | public abstract boolean supportsMultiFile(); 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/HastebinPasteService.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils.webpaste; 2 | 3 | import org.json.simple.JSONObject; 4 | import org.json.simple.parser.JSONParser; 5 | import org.json.simple.parser.ParseException; 6 | 7 | import java.io.IOException; 8 | import java.util.Map; 9 | 10 | /** 11 | * Pastes to {@code hastebin.com}. 12 | */ 13 | class HastebinPasteService extends PasteService { 14 | private static final String HASTEBIN_POST_REQUEST = "https://hastebin.com/documents"; 15 | 16 | HastebinPasteService() { 17 | super(HASTEBIN_POST_REQUEST); 18 | } 19 | 20 | /** 21 | * {@inheritDoc} 22 | */ 23 | @Override 24 | String encodeData(String data) { 25 | return data; 26 | } 27 | 28 | /** 29 | * {@inheritDoc} 30 | */ 31 | @Override 32 | String encodeData(Map data) { 33 | throw new UnsupportedOperationException(); 34 | } 35 | 36 | /** 37 | * {@inheritDoc} 38 | */ 39 | @Override 40 | public String postData(String data) throws PasteFailedException { 41 | try { 42 | String stringJSON = this.exec(encodeData(data), ContentType.PLAINTEXT); 43 | return "https://hastebin.com/" + ((JSONObject) new JSONParser().parse(stringJSON)).get("key"); 44 | } catch (IOException | ParseException e) { 45 | throw new PasteFailedException(e); 46 | } 47 | } 48 | 49 | /** 50 | * {@inheritDoc} 51 | */ 52 | @Override 53 | public String postData(Map data) throws PasteFailedException { 54 | try { 55 | String stringJSON = this.exec(encodeData(data), ContentType.PLAINTEXT); 56 | return "https://hastebin.com/" + ((JSONObject) new JSONParser().parse(stringJSON)).get("key"); 57 | } catch (IOException | ParseException e) { 58 | throw new PasteFailedException(e); 59 | } 60 | } 61 | 62 | /** 63 | * {@inheritDoc} 64 | */ 65 | @Override 66 | public boolean supportsMultiFile() { 67 | return false; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/api/MVPlugin.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.api; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import com.onarandombox.MultiverseCore.event.MVVersionEvent; 12 | 13 | /** 14 | * This interface is implemented by every official Multiverse-plugin. 15 | */ 16 | public interface MVPlugin extends LoggablePlugin { 17 | /** 18 | * Adds This plugin's version information to the buffer and returns the new string. 19 | * 20 | * @param buffer The string that contains Core and all other MV plugins' versions. 21 | * 22 | * @return A modified buffer that contains this MVPlugin's version information. 23 | * 24 | * @deprecated This is now deprecated, nobody needs it any longer. 25 | * All version info-dumping is now done with {@link MVVersionEvent}. 26 | */ 27 | @Deprecated 28 | String dumpVersionInfo(String buffer); 29 | 30 | /** 31 | * Gets the reference to MultiverseCore. 32 | * 33 | * @return A valid {@link com.onarandombox.MultiverseCore}. 34 | */ 35 | MultiverseCore getCore(); 36 | 37 | /** 38 | * Sets the reference to MultiverseCore. 39 | * 40 | * @param core A valid {@link com.onarandombox.MultiverseCore}. 41 | */ 42 | void setCore(MultiverseCore core); 43 | 44 | /** 45 | * Allows Multiverse or a plugin to query another Multiverse plugin to see what version its protocol is. This 46 | * number 47 | * should change when something will break the code. 48 | * 49 | * @return The Integer protocol version. 50 | */ 51 | int getProtocolVersion(); 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/event/MVWorldDeleteEvent.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.event; 2 | 3 | import org.bukkit.event.Cancellable; 4 | import org.bukkit.event.Event; 5 | 6 | import com.onarandombox.MultiverseCore.api.MultiverseWorld; 7 | import org.bukkit.event.HandlerList; 8 | 9 | /** 10 | * Called when a world is about to be deleted by Multiverse. 11 | */ 12 | public class MVWorldDeleteEvent extends Event implements Cancellable { 13 | private boolean cancelled = false; 14 | 15 | private final MultiverseWorld world; 16 | private final boolean removeFromConfig; 17 | 18 | public MVWorldDeleteEvent(MultiverseWorld world, boolean removeFromConfig) { 19 | if (world == null) 20 | throw new IllegalArgumentException("world can't be null!"); 21 | 22 | this.world = world; 23 | this.removeFromConfig = removeFromConfig; 24 | } 25 | 26 | private static final HandlerList HANDLERS = new HandlerList(); 27 | 28 | /** 29 | * {@inheritDoc} 30 | */ 31 | @Override 32 | public HandlerList getHandlers() { 33 | return HANDLERS; 34 | } 35 | 36 | /** 37 | * Gets the handler list. This is required by the event system. 38 | * @return A list of HANDLERS. 39 | */ 40 | public static HandlerList getHandlerList() { 41 | return HANDLERS; 42 | } 43 | 44 | /** 45 | * {@inheritDoc} 46 | */ 47 | @Override 48 | public boolean isCancelled() { 49 | return cancelled; 50 | } 51 | 52 | /** 53 | * {@inheritDoc} 54 | */ 55 | @Override 56 | public void setCancelled(boolean cancel) { 57 | cancelled = cancel; 58 | } 59 | 60 | /** 61 | * Gets the world that's about to be deleted. 62 | * 63 | * @return That {@link MultiverseWorld}. 64 | */ 65 | public MultiverseWorld getWorld() { 66 | return world; 67 | } 68 | 69 | /** 70 | * Is the world about to be removed from the config? 71 | * 72 | * @return True if yes, false if no. 73 | */ 74 | public boolean removeWorldFromConfig() { 75 | return removeFromConfig; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/display/handlers/InlineMapDisplayHandler.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.display.handlers; 2 | 3 | import com.onarandombox.MultiverseCore.display.ContentDisplay; 4 | import com.onarandombox.MultiverseCore.display.DisplayFormatException; 5 | import com.onarandombox.MultiverseCore.display.DisplayHandler; 6 | import com.onarandombox.MultiverseCore.display.settings.InlineDisplaySettings; 7 | import com.onarandombox.MultiverseCore.display.settings.MapDisplaySettings; 8 | import org.bukkit.command.CommandSender; 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import java.util.Collection; 12 | import java.util.Collections; 13 | import java.util.Iterator; 14 | import java.util.Map; 15 | 16 | public class InlineMapDisplayHandler implements DisplayHandler> { 17 | 18 | @Override 19 | public Collection format(@NotNull CommandSender sender, 20 | @NotNull ContentDisplay> display) 21 | throws DisplayFormatException { 22 | StringBuilder builder = new StringBuilder(); 23 | String separator = display.getSetting(InlineDisplaySettings.SEPARATOR); 24 | String operator = display.getSetting(MapDisplaySettings.OPERATOR); 25 | 26 | for (Iterator> iterator = display.getContents().entrySet().iterator(); iterator.hasNext(); ) { 27 | Map.Entry entry = iterator.next(); 28 | if (!display.getFilter().checkMatch(entry.getKey()) && !display.getFilter().checkMatch(entry.getValue())) { 29 | continue; 30 | } 31 | builder.append(display.getColorTool().get()) 32 | .append(entry.getKey()) 33 | .append(operator) 34 | .append(display.getColorTool().get()) 35 | .append(entry.getValue()); 36 | if (iterator.hasNext()) { 37 | builder.append(separator); 38 | } 39 | } 40 | return (builder.length() == 0) 41 | ? Collections.singletonList(display.getEmptyMessage()) 42 | : Collections.singleton(builder.toString()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/SilentCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import org.bukkit.ChatColor; 12 | import org.bukkit.command.CommandSender; 13 | import org.bukkit.permissions.PermissionDefault; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * Enables debug-information. 19 | */ 20 | public class SilentCommand extends MultiverseCommand { 21 | 22 | public SilentCommand(MultiverseCore plugin) { 23 | super(plugin); 24 | this.setName("Turn silent mode on/off?"); 25 | this.setCommandUsage("/mv silent" + ChatColor.GOLD + " [true|false|on|off]"); 26 | this.setArgRange(0, 1); 27 | this.addKey("mv silent"); 28 | this.addKey("mvsilent"); 29 | this.addCommandExample("/mv silent " + ChatColor.GOLD + "true"); 30 | this.setPermission("multiverse.core.silent", "Reduces the amount of startup messages.", PermissionDefault.OP); 31 | } 32 | 33 | @Override 34 | public void runCommand(CommandSender sender, List args) { 35 | if (args.size() == 1) { 36 | if (args.get(0).equalsIgnoreCase("on")) { 37 | args.set(0, "true"); 38 | } 39 | plugin.getMVConfig().setSilentStart(Boolean.valueOf(args.get(0))); 40 | plugin.saveMVConfigs(); 41 | } 42 | this.displaySilentMode(sender); 43 | } 44 | 45 | private void displaySilentMode(CommandSender sender) { 46 | if (plugin.getMVConfig().getSilentStart()) { 47 | sender.sendMessage("Multiverse Silent Start mode is " + ChatColor.GREEN + "ON"); 48 | } else { 49 | sender.sendMessage("Multiverse Silent Start mode is " + ChatColor.RED + "OFF"); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/FancyColorScheme.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.utils; 9 | 10 | import org.bukkit.ChatColor; 11 | 12 | /** 13 | * A color-scheme. 14 | */ 15 | public class FancyColorScheme { 16 | private ChatColor headerColor; 17 | private ChatColor mainColor; 18 | private ChatColor altColor; 19 | private ChatColor defContentColor; 20 | 21 | public FancyColorScheme(ChatColor header, ChatColor main, ChatColor alt, ChatColor defaultColor) { 22 | this.headerColor = header; 23 | this.mainColor = main; 24 | this.altColor = alt; 25 | this.defContentColor = defaultColor; 26 | } 27 | 28 | /** 29 | * Gets the header's {@link ChatColor}. 30 | * @return The header's {@link ChatColor}. 31 | */ 32 | public ChatColor getHeader() { 33 | return this.headerColor; 34 | } 35 | 36 | /** 37 | * Gets the main {@link ChatColor}. 38 | * @return The main {@link ChatColor}. 39 | */ 40 | public ChatColor getMain() { 41 | return this.mainColor; 42 | } 43 | 44 | /** 45 | * Gets the alt {@link ChatColor}. 46 | * @return The alt {@link ChatColor}. 47 | */ 48 | public ChatColor getAlt() { 49 | return this.altColor; 50 | } 51 | 52 | /** 53 | * Gets the default {@link ChatColor}. 54 | * @return The default {@link ChatColor}. 55 | */ 56 | public ChatColor getDefault() { 57 | return this.defContentColor; 58 | } 59 | 60 | /** 61 | * Gets either the main or the alt {@link ChatColor}. 62 | * @param main True if the main-color is desired, false to get the alt color. 63 | * @return The desired {@link ChatColor}. 64 | */ 65 | public ChatColor getMain(boolean main) { 66 | return main ? this.getMain() : this.getAlt(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/api/MultiverseMessaging.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.api; 2 | 3 | import java.util.Collection; 4 | 5 | import org.bukkit.command.CommandSender; 6 | 7 | /** 8 | * Multiverse-messaging. 9 | */ 10 | public interface MultiverseMessaging { 11 | /** 12 | * Sets the message-cooldown. 13 | * @param milliseconds The new message-cooldown in milliseconds. 14 | */ 15 | void setCooldown(int milliseconds); 16 | 17 | /** 18 | * Sends a message to the specified sender if the cooldown has passed. 19 | * 20 | * @param sender The person/console to send the message to. 21 | * @param message The message to send. 22 | * @param ignoreCooldown If true this message will always be sent. Useful for things like menus 23 | * @return true if the message was sent, false if not. 24 | */ 25 | boolean sendMessage(CommandSender sender, String message, boolean ignoreCooldown); 26 | 27 | /** 28 | * Sends a group of messages to the specified sender if the cooldown has passed. 29 | * This method is needed, since sending many messages in quick succession would violate 30 | * the cooldown. 31 | * 32 | * @param sender The person/console to send the message to. 33 | * @param messages The messages to send. 34 | * @param ignoreCooldown If true these messages will always be sent. Useful for things like menus 35 | * @return true if the message was sent, false if not. 36 | */ 37 | boolean sendMessages(CommandSender sender, String[] messages, boolean ignoreCooldown); 38 | 39 | /** 40 | * Sends a group of messages to the specified sender if the cooldown has passed. 41 | * This method is needed, since sending many messages in quick succession would violate 42 | * the cooldown. 43 | * 44 | * @param sender The person/console to send the message to. 45 | * @param messages The messages to send. 46 | * @param ignoreCooldown If true these messages will always be sent. Useful for things like menus 47 | * @return true if the message was sent, false if not. 48 | */ 49 | boolean sendMessages(CommandSender sender, Collection messages, boolean ignoreCooldown); 50 | 51 | /** 52 | * Gets the message-cooldown. 53 | * @return The message-cooldown. 54 | */ 55 | int getCooldown(); 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/listeners/MVWeatherListener.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.listeners; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import com.onarandombox.MultiverseCore.api.MultiverseWorld; 12 | import org.bukkit.event.EventHandler; 13 | import org.bukkit.event.Listener; 14 | import org.bukkit.event.weather.ThunderChangeEvent; 15 | import org.bukkit.event.weather.WeatherChangeEvent; 16 | 17 | /** 18 | * Multiverse's Weather {@link Listener}. 19 | */ 20 | public class MVWeatherListener implements Listener { 21 | private MultiverseCore plugin; 22 | 23 | public MVWeatherListener(MultiverseCore plugin) { 24 | this.plugin = plugin; 25 | } 26 | 27 | /** 28 | * This method is called when the weather changes. 29 | * @param event The Event that was fired. 30 | */ 31 | @EventHandler 32 | public void weatherChange(WeatherChangeEvent event) { 33 | if (event.isCancelled()) { 34 | return; 35 | } 36 | MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld().getName()); 37 | if (world != null) { 38 | // If it's going to start raining and we have weather disabled 39 | event.setCancelled((event.toWeatherState() && !world.isWeatherEnabled())); 40 | } 41 | } 42 | 43 | /** 44 | * This method is called when a big storm is going to start. 45 | * @param event The Event that was fired. 46 | */ 47 | @EventHandler 48 | public void thunderChange(ThunderChangeEvent event) { 49 | if (event.isCancelled()) { 50 | return; 51 | } 52 | MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld().getName()); 53 | if (world != null) { 54 | // If it's going to start raining and we have weather disabled 55 | event.setCancelled((event.toThunderState() && !world.isWeatherEnabled())); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/configuration/EntryFee.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.configuration; 2 | 3 | import java.util.Map; 4 | 5 | import com.onarandombox.MultiverseCore.utils.MaterialConverter; 6 | import me.main__.util.SerializationConfig.Property; 7 | import me.main__.util.SerializationConfig.SerializationConfig; 8 | 9 | import me.main__.util.SerializationConfig.Serializor; 10 | import org.bukkit.Material; 11 | import org.bukkit.configuration.serialization.SerializableAs; 12 | import org.jetbrains.annotations.Nullable; 13 | 14 | /** 15 | * Entryfee-settings. 16 | */ 17 | @SerializableAs("MVEntryFee") 18 | public class EntryFee extends SerializationConfig { 19 | @Property 20 | private double amount; 21 | @Property(serializor = EntryFeeCurrencySerializor.class) 22 | @Nullable 23 | private Material currency; 24 | 25 | private final Material DISABLED_MATERIAL = Material.AIR; 26 | 27 | public EntryFee() { 28 | super(); 29 | } 30 | 31 | public EntryFee(Map values) { 32 | super(values); 33 | } 34 | 35 | /** 36 | * {@inheritDoc} 37 | */ 38 | @Override 39 | protected void setDefaults() { 40 | amount = 0D; 41 | currency = null; 42 | } 43 | 44 | /** 45 | * @return the amount 46 | */ 47 | public double getAmount() { 48 | return amount; 49 | } 50 | 51 | /** 52 | * @return the currency 53 | */ 54 | @Nullable 55 | public Material getCurrency() { 56 | if (currency == null || currency.equals(DISABLED_MATERIAL)) { 57 | return null; 58 | } 59 | return currency; 60 | } 61 | 62 | /** 63 | * Sets the amount. 64 | * @param amount The new value. 65 | */ 66 | public void setAmount(double amount) { 67 | this.amount = amount; 68 | } 69 | 70 | /** 71 | * Sets the currency. 72 | * @param currency The new value. 73 | */ 74 | public void setCurrency(@Nullable Material currency) { 75 | this.currency = currency; 76 | } 77 | 78 | public static final class EntryFeeCurrencySerializor implements Serializor { 79 | @Override 80 | public String serialize(Material material) { 81 | return material.toString(); 82 | } 83 | 84 | @Override 85 | public Material deserialize(Object o, Class aClass) { 86 | return MaterialConverter.convertTypeString(o.toString()); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/FancyMessage.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.utils; 9 | 10 | import com.onarandombox.MultiverseCore.api.FancyText; 11 | 12 | /** 13 | * A colored text-message. 14 | */ 15 | public class FancyMessage implements FancyText { 16 | private String title; 17 | private String message; 18 | private boolean main = true; 19 | private FancyColorScheme colors; 20 | 21 | /** 22 | * Allows easy creation of an alternating colored list. 23 | * TODO: Documentation! Why does CheckStyle just ignore this? 24 | * 25 | * @param title The title. 26 | * @param message The body of the message. 27 | * @param scheme The color scheme to use for easy styling. 28 | */ 29 | public FancyMessage(String title, String message, FancyColorScheme scheme) { 30 | this.title = title; 31 | this.message = message; 32 | this.colors = scheme; 33 | } 34 | 35 | /** 36 | * Makes this {@link FancyMessage} use the main-color. 37 | */ 38 | public void setColorMain() { 39 | this.main = true; 40 | } 41 | 42 | /** 43 | * Makes this {@link FancyMessage} use the alt-color. 44 | */ 45 | public void setColorAlt() { 46 | this.main = false; 47 | } 48 | 49 | @Override 50 | public String getFancyText() { 51 | return this.colors.getMain(this.main) + this.title + this.colors.getDefault() + message; 52 | } 53 | 54 | /** 55 | * Specifies whether this {@link FancyMessage} should use the alt-color. 56 | * @param altColor Whether this {@link FancyMessage} should use the alt-color. 57 | */ 58 | public void setAltColor(boolean altColor) { 59 | this.main = !altColor; 60 | } 61 | 62 | /** 63 | * Specifies whether this {@link FancyMessage} should use the main-color. 64 | * @param mainColor Whether this {@link FancyMessage} should use the main-color. 65 | */ 66 | public void setMainColor(boolean mainColor) { 67 | this.main = mainColor; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/event/MVRespawnEvent.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.event; 9 | 10 | import org.bukkit.Location; 11 | import org.bukkit.entity.Player; 12 | import org.bukkit.event.Event; 13 | import org.bukkit.event.HandlerList; 14 | 15 | /** 16 | * Called when a player is respawning. 17 | */ 18 | public class MVRespawnEvent extends Event { 19 | private Player player; 20 | private Location location; 21 | private String respawnMethod; 22 | 23 | 24 | public MVRespawnEvent(Location spawningAt, Player p, String respawnMethod) { 25 | this.player = p; 26 | this.location = spawningAt; 27 | this.respawnMethod = respawnMethod; 28 | } 29 | 30 | private static final HandlerList HANDLERS = new HandlerList(); 31 | 32 | /** 33 | * {@inheritDoc} 34 | */ 35 | @Override 36 | public HandlerList getHandlers() { 37 | return HANDLERS; 38 | } 39 | 40 | /** 41 | * Gets the handler list. This is required by the event system. 42 | * @return A list of HANDLERS. 43 | */ 44 | public static HandlerList getHandlerList() { 45 | return HANDLERS; 46 | } 47 | 48 | /** 49 | * Gets the {@link Player} that's respawning. 50 | * @return The {@link Player} that's respawning. 51 | */ 52 | public Player getPlayer() { 53 | return this.player; 54 | } 55 | 56 | /** 57 | * Gets the respawn-method. 58 | * @return The respawn-method. 59 | */ 60 | public String getRespawnMethod() { 61 | return this.respawnMethod; 62 | } 63 | 64 | /** 65 | * Gets the player's respawn-{@link Location}. 66 | * @return The player's respawn-{@link Location}. 67 | */ 68 | public Location getPlayersRespawnLocation() { 69 | return this.location; 70 | } 71 | 72 | /** 73 | * Sets the player's respawn-{@link Location}. 74 | * @param l The new respawn-{@link Location}. 75 | */ 76 | public void setRespawnLocation(Location l) { 77 | this.location = l; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/listeners/MVChatListener.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.listeners; 2 | 3 | import com.onarandombox.MultiverseCore.MultiverseCore; 4 | import com.onarandombox.MultiverseCore.api.MVWorldManager; 5 | import com.onarandombox.MultiverseCore.api.MultiverseWorld; 6 | 7 | import org.bukkit.ChatColor; 8 | import org.bukkit.event.Listener; 9 | 10 | /** 11 | * Multiverse's {@link org.bukkit.event.Listener} for players. 12 | */ 13 | public abstract class MVChatListener implements Listener { 14 | private final MultiverseCore plugin; 15 | private final MVWorldManager worldManager; 16 | private final MVPlayerListener playerListener; 17 | 18 | public MVChatListener(MultiverseCore plugin, MVPlayerListener playerListener) { 19 | this.plugin = plugin; 20 | this.worldManager = plugin.getMVWorldManager(); 21 | this.playerListener = playerListener; 22 | } 23 | 24 | /** 25 | * This handles a {@link ChatEvent}. 26 | * @param event The {@link ChatEvent}. 27 | */ 28 | public void playerChat(ChatEvent event) { 29 | if (event.isCancelled()) { 30 | return; 31 | } 32 | // Check whether the Server is set to prefix the chat with the World name. 33 | // If not we do nothing, if so we need to check if the World has an Alias. 34 | if (plugin.getMVConfig().getPrefixChat()) { 35 | String world = playerListener.getPlayerWorld().get(event.getPlayer().getName()); 36 | if (world == null) { 37 | world = event.getPlayer().getWorld().getName(); 38 | playerListener.getPlayerWorld().put(event.getPlayer().getName(), world); 39 | } 40 | String prefix = ""; 41 | // If we're not a MV world, don't do anything 42 | if (!this.worldManager.isMVWorld(world)) { 43 | return; 44 | } 45 | MultiverseWorld mvworld = this.worldManager.getMVWorld(world); 46 | if (mvworld.isHidden()) { 47 | return; 48 | } 49 | prefix = mvworld.getColoredWorldString(); 50 | String chat = event.getFormat(); 51 | 52 | String prefixChatFormat = plugin.getMVConfig().getPrefixChatFormat(); 53 | prefixChatFormat = prefixChatFormat.replace("%world%", prefix).replace("%chat%", chat); 54 | prefixChatFormat = ChatColor.translateAlternateColorCodes('&', prefixChatFormat); 55 | 56 | event.setFormat(prefixChatFormat); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/ReloadCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent; 12 | import org.bukkit.ChatColor; 13 | import org.bukkit.command.CommandSender; 14 | import org.bukkit.permissions.PermissionDefault; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | /** 20 | * Reloads worlds.yml and config.yml. 21 | */ 22 | public class ReloadCommand extends MultiverseCommand { 23 | 24 | public ReloadCommand(MultiverseCore plugin) { 25 | super(plugin); 26 | this.setName("Reload Configs"); 27 | this.setCommandUsage("/mv reload"); 28 | this.setArgRange(0, 0); 29 | this.addKey("mvreload"); 30 | this.addKey("mvr"); 31 | this.addKey("mv reload"); 32 | this.addCommandExample("/mv reload"); 33 | this.setPermission("multiverse.core.reload", "Reloads worlds.yml and config.yml.", PermissionDefault.OP); 34 | } 35 | 36 | @Override 37 | public void runCommand(CommandSender sender, List args) { 38 | sender.sendMessage(ChatColor.GOLD + "Reloading all Multiverse Plugin configs..."); 39 | this.plugin.loadConfigs(); 40 | this.plugin.getAnchorManager().loadAnchors(); 41 | this.plugin.getMVWorldManager().loadWorlds(true); 42 | 43 | List configsLoaded = new ArrayList(); 44 | configsLoaded.add("Multiverse-Core - config.yml"); 45 | configsLoaded.add("Multiverse-Core - worlds.yml"); 46 | configsLoaded.add("Multiverse-Core - anchors.yml"); 47 | // Create the event 48 | MVConfigReloadEvent configReload = new MVConfigReloadEvent(configsLoaded); 49 | // Fire it off 50 | this.plugin.getServer().getPluginManager().callEvent(configReload); 51 | for (String s : configReload.getAllConfigsLoaded()) { 52 | sender.sendMessage(s); 53 | } 54 | 55 | sender.sendMessage(ChatColor.GREEN + "Reload Complete!"); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/ScriptCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import org.bukkit.ChatColor; 12 | import org.bukkit.command.CommandSender; 13 | import org.bukkit.entity.Player; 14 | import org.bukkit.permissions.PermissionDefault; 15 | 16 | import java.io.File; 17 | import java.util.List; 18 | 19 | /** 20 | * States who is in what world. 21 | */ 22 | public class ScriptCommand extends MultiverseCommand { 23 | 24 | public ScriptCommand(MultiverseCore plugin) { 25 | super(plugin); 26 | this.setName("Runs a script."); 27 | this.setCommandUsage("/mv script" + ChatColor.GOLD + " {script} [target]"); 28 | this.setArgRange(1, 2); 29 | this.addKey("mv script"); 30 | this.addKey("mvscript"); 31 | this.addCommandExample(String.format("/mv script %sscript.txt", ChatColor.GOLD)); 32 | this.addCommandExample(String.format("/mv script %stest.txt %ssomeplayer", ChatColor.GOLD, ChatColor.GREEN)); 33 | this.setPermission("multiverse.core.script", "Runs a script.", PermissionDefault.OP); 34 | } 35 | 36 | @Override 37 | public void runCommand(CommandSender sender, List args) { 38 | if (plugin.getScriptAPI() == null) { 39 | sender.sendMessage("Buscript failed to load while the server was starting. Scripts cannot be run."); 40 | return; 41 | } 42 | File file = new File(plugin.getScriptAPI().getScriptFolder(), args.get(0)); 43 | if (!file.exists()) { 44 | sender.sendMessage("That script file does not exist in the Multiverse-Core scripts directory!"); 45 | return; 46 | } 47 | Player player = null; 48 | if (sender instanceof Player) { 49 | player = (Player) sender; 50 | } 51 | String target = null; 52 | if (args.size() == 2) { 53 | target = args.get(1); 54 | } 55 | plugin.getScriptAPI().executeScript(file, target, player); 56 | sender.sendMessage(String.format("Script '%s%s%s' finished!", ChatColor.GOLD, file.getName(), ChatColor.WHITE)); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import java.util.List; 11 | 12 | import org.bukkit.ChatColor; 13 | import org.bukkit.command.CommandSender; 14 | import org.bukkit.permissions.PermissionDefault; 15 | 16 | import com.onarandombox.MultiverseCore.MultiverseCore; 17 | import com.onarandombox.MultiverseCore.api.MVWorldManager; 18 | 19 | /** 20 | * Creates a clone of a world. 21 | */ 22 | public class CloneCommand extends MultiverseCommand { 23 | private MVWorldManager worldManager; 24 | 25 | public CloneCommand(MultiverseCore plugin) { 26 | super(plugin); 27 | this.setName("Clone World"); 28 | this.setCommandUsage("/mv clone" + ChatColor.GREEN + " {TARGET} {NAME}" + ChatColor.GOLD + " -g [GENERATOR[:ID]]"); 29 | this.setArgRange(2, 4); // SUPPRESS CHECKSTYLE: MagicNumberCheck 30 | this.addKey("mvclone"); 31 | this.addKey("mvcl"); 32 | this.addKey("mv cl"); 33 | this.addKey("mv clone"); 34 | this.addCommandExample("/mv clone " + ChatColor.GOLD + "world" + ChatColor.GREEN + " world_backup"); 35 | this.addCommandExample("/mv clone " + ChatColor.GOLD + "skyblock_pristine" + ChatColor.GREEN + " skyblock"); 36 | this.setPermission("multiverse.core.clone", "Clones a world.", PermissionDefault.OP); 37 | this.worldManager = this.plugin.getMVWorldManager(); 38 | } 39 | 40 | @Override 41 | public void runCommand(CommandSender sender, List args) { 42 | String oldName = args.get(0); 43 | if (!this.worldManager.hasUnloadedWorld(oldName, true)) { 44 | // If no world was found, we can't clone. 45 | sender.sendMessage("Sorry, Multiverse doesn't know about world " + oldName + ", so we can't clone it!"); 46 | sender.sendMessage("Check the " + ChatColor.GREEN + "/mv list" + ChatColor.WHITE + " command to verify it is listed."); 47 | return; 48 | } 49 | if (this.plugin.getMVWorldManager().cloneWorld(oldName, args.get(1))) { 50 | sender.sendMessage(ChatColor.GREEN + "World cloned!"); 51 | } else { 52 | sender.sendMessage(ChatColor.RED + "World could NOT be cloned!"); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/GeneratorCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.dumptruckman.minecraft.util.Logging; 11 | import com.onarandombox.MultiverseCore.MultiverseCore; 12 | import org.bukkit.ChatColor; 13 | import org.bukkit.command.CommandSender; 14 | import org.bukkit.permissions.PermissionDefault; 15 | import org.bukkit.plugin.Plugin; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | /** 21 | * Returns a list of loaded generator plugins. 22 | */ 23 | public class GeneratorCommand extends MultiverseCommand { 24 | 25 | public GeneratorCommand(MultiverseCore plugin) { 26 | super(plugin); 27 | this.setName("World Information"); 28 | this.setCommandUsage("/mv generators"); 29 | this.setArgRange(0, 0); 30 | this.addKey("mv generators"); 31 | this.addKey("mvgenerators"); 32 | this.addKey("mv gens"); 33 | this.addKey("mvgens"); 34 | this.addCommandExample("/mv generators"); 35 | this.setPermission("multiverse.core.generator", "Returns a list of Loaded Generator Plugins.", PermissionDefault.OP); 36 | } 37 | 38 | @Override 39 | public void runCommand(CommandSender sender, List args) { 40 | Logging.info("PLEASE IGNORE the 'Plugin X does not contain any generators' message below!"); 41 | Plugin[] plugins = this.plugin.getServer().getPluginManager().getPlugins(); 42 | List generators = new ArrayList(); 43 | for (Plugin p : plugins) { 44 | if (p.isEnabled() && p.getDefaultWorldGenerator("world", "") != null) { 45 | generators.add(p.getDescription().getName()); 46 | } 47 | } 48 | sender.sendMessage(ChatColor.AQUA + "--- Loaded Generator Plugins ---"); 49 | String loadedGens = ""; 50 | boolean altColor = false; 51 | for (String s : generators) { 52 | loadedGens += (altColor ? ChatColor.YELLOW : ChatColor.WHITE) + s + " "; 53 | altColor = !altColor; 54 | } 55 | if (loadedGens.length() == 0) { 56 | loadedGens = ChatColor.RED + "No Generator Plugins found."; 57 | } 58 | sender.sendMessage(loadedGens); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/PastebinPasteService.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils.webpaste; 2 | 3 | import java.io.IOException; 4 | import java.io.UnsupportedEncodingException; 5 | import java.net.URLEncoder; 6 | import java.util.Map; 7 | 8 | /** 9 | * Pastes to {@code pastebin.com}. 10 | */ 11 | class PastebinPasteService extends PasteService { 12 | private final boolean isPrivate; 13 | private static final String PASTEBIN_POST_REQUEST = "https://pastebin.com/api/api_post.php"; 14 | 15 | PastebinPasteService(boolean isPrivate) { 16 | super(PASTEBIN_POST_REQUEST); 17 | this.isPrivate = isPrivate; 18 | } 19 | 20 | /** 21 | * {@inheritDoc} 22 | */ 23 | @Override 24 | String encodeData(String data) { 25 | try { 26 | return URLEncoder.encode("api_dev_key", "UTF-8") + "=" + URLEncoder.encode("d61d68d31e8e0392b59b50b277411c71", "UTF-8") + 27 | "&" + URLEncoder.encode("api_option", "UTF-8") + "=" + URLEncoder.encode("paste", "UTF-8") + 28 | "&" + URLEncoder.encode("api_paste_code", "UTF-8") + "=" + URLEncoder.encode(data, "UTF-8") + 29 | "&" + URLEncoder.encode("api_paste_private", "UTF-8") + "=" + URLEncoder.encode(this.isPrivate ? "1" : "0", "UTF-8") + 30 | "&" + URLEncoder.encode("api_paste_format", "UTF-8") + "=" + URLEncoder.encode("yaml", "UTF-8") + 31 | "&" + URLEncoder.encode("api_paste_name", "UTF-8") + "=" + URLEncoder.encode("Multiverse-Core Debug Info", "UTF-8"); 32 | } catch (UnsupportedEncodingException e) { 33 | return ""; // should never hit here 34 | } 35 | } 36 | 37 | /** 38 | * {@inheritDoc} 39 | */ 40 | @Override 41 | String encodeData(Map data) { 42 | throw new UnsupportedOperationException(); 43 | } 44 | 45 | /** 46 | * {@inheritDoc} 47 | */ 48 | @Override 49 | public String postData(String data) throws PasteFailedException { 50 | try { 51 | return this.exec(encodeData(data), ContentType.URLENCODED); 52 | } catch (IOException e) { 53 | throw new PasteFailedException(e); 54 | } 55 | } 56 | 57 | /** 58 | * {@inheritDoc} 59 | */ 60 | @Override 61 | public String postData(Map data) throws PasteFailedException { 62 | try { 63 | return this.exec(encodeData(data), ContentType.URLENCODED); 64 | } catch (IOException e) { 65 | throw new PasteFailedException(e); 66 | } 67 | } 68 | 69 | /** 70 | * {@inheritDoc} 71 | */ 72 | @Override 73 | public boolean supportsMultiFile() { 74 | return false; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import com.onarandombox.MultiverseCore.commandtools.queue.QueuedCommand; 12 | import org.bukkit.ChatColor; 13 | import org.bukkit.command.CommandSender; 14 | import org.bukkit.permissions.PermissionDefault; 15 | import org.jetbrains.annotations.NotNull; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | /** 21 | * Deletes worlds. 22 | */ 23 | public class DeleteCommand extends MultiverseCommand { 24 | 25 | public DeleteCommand(MultiverseCore plugin) { 26 | super(plugin); 27 | this.setName("Delete World"); 28 | this.setCommandUsage("/mv delete" + ChatColor.GREEN + " {WORLD}"); 29 | this.setArgRange(1, 1); 30 | this.addKey("mvdelete"); 31 | this.addKey("mv delete"); 32 | this.addCommandExample("/mv delete " + ChatColor.GOLD + "MyWorld"); 33 | this.setPermission("multiverse.core.delete", "Deletes a world on your server. " + ChatColor.RED + "PERMANENTLY.", PermissionDefault.OP); 34 | } 35 | 36 | @Override 37 | public void runCommand(CommandSender sender, List args) { 38 | String worldName = args.get(0); 39 | 40 | this.plugin.getCommandQueueManager().addToQueue(new QueuedCommand( 41 | sender, 42 | deleteRunnable(sender, worldName), 43 | String.format("Are you sure you want to delete world '%s'? You cannot undo this action.", worldName) 44 | )); 45 | } 46 | 47 | private Runnable deleteRunnable(@NotNull CommandSender sender, 48 | @NotNull String worldName) { 49 | 50 | return () -> { 51 | sender.sendMessage(String.format("Deleting world '%s'...", worldName)); 52 | if (this.plugin.getMVWorldManager().deleteWorld(worldName)) { 53 | sender.sendMessage(String.format("%sWorld %s was deleted!", ChatColor.GREEN, worldName)); 54 | return; 55 | } 56 | sender.sendMessage(String.format("%sThere was an issue deleting '%s'! Please check console for errors.", 57 | ChatColor.RED, worldName)); 58 | }; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /.github/workflows/call.platform_uploads.yml: -------------------------------------------------------------------------------- 1 | name: 'Call: Platform Uploads' 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | target_tag: 7 | description: 'Version to upload' 8 | required: true 9 | type: string 10 | upload_modrinth: 11 | description: 'Upload to modrinth.com' 12 | required: true 13 | type: string 14 | upload_dbo: 15 | description: 'Upload to dev.bukkit.org' 16 | required: true 17 | type: string 18 | upload_hangar: 19 | description: 'Upload to hangar.papermc.io' 20 | required: true 21 | type: string 22 | secrets: 23 | MODRINTH_TOKEN: 24 | required: true 25 | DBO_UPLOAD_API_TOKEN: 26 | required: true 27 | HANGAR_UPLOAD_TOKEN: 28 | required: true 29 | 30 | jobs: 31 | platform_uploads: 32 | uses: ./.github/workflows/generic.platform_uploads.yml 33 | secrets: inherit 34 | with: 35 | plugin_name: multiverse-core 36 | modrinth_project_id: 3wmN97b8 37 | modrinth_dependencies: > 38 | [ 39 | {"project_id": "qvdtDX3s", "dependency_type": "optional"}, 40 | {"project_id": "8VMk6P0I", "dependency_type": "optional"}, 41 | {"project_id": "vtawPsTo", "dependency_type": "optional"}, 42 | {"project_id": "WuErDeI1", "dependency_type": "optional"} 43 | ] 44 | 45 | dbo_project_id: 30765 46 | dbo_project_relations: > 47 | [ 48 | {"slug": "multiverse-inventories", "type": "optionalDependency"}, 49 | {"slug": "multiverse-portals", "type": "optionalDependency"}, 50 | {"slug": "multiverse-netherportals", "type": "optionalDependency"}, 51 | {"slug": "multiverse-signportals", "type": "optionalDependency"}, 52 | {"slug": "vault", "type": "optionalDependency"} 53 | ] 54 | 55 | hangar_slug: Multiverse-Core 56 | hangar_plugin_dependencies: > 57 | { "PAPER": [ 58 | { 59 | "name": "Multiverse-Inventories", 60 | "required": false, 61 | "platforms": ["PAPER"] 62 | }, 63 | { 64 | "name": "Multiverse-Portals", 65 | "required": false, 66 | "platforms": ["PAPER"] 67 | }, 68 | { 69 | "name": "Multiverse-NetherPortals", 70 | "required": false, 71 | "platforms": ["PAPER"] 72 | }, 73 | { 74 | "name": "Multiverse-SignPortals", 75 | "required": false, 76 | "platforms": ["PAPER"] 77 | } 78 | ]} 79 | 80 | target_tag: ${{ inputs.target_tag }} 81 | upload_modrinth: ${{ inputs.upload_modrinth }} 82 | upload_dbo: ${{ inputs.upload_dbo }} 83 | upload_hangar: ${{ inputs.upload_hangar }} 84 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/listeners/MVWorldListener.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.listeners; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import com.onarandombox.MultiverseCore.api.MVWorldManager; 12 | import com.onarandombox.MultiverseCore.api.MultiverseWorld; 13 | import org.bukkit.World; 14 | import org.bukkit.event.EventHandler; 15 | import org.bukkit.event.Listener; 16 | import org.bukkit.event.world.WorldLoadEvent; 17 | import org.bukkit.event.world.WorldUnloadEvent; 18 | 19 | /** 20 | * Multiverse's World {@link Listener}. 21 | */ 22 | public class MVWorldListener implements Listener { 23 | private MultiverseCore plugin; 24 | private MVWorldManager worldManager; 25 | 26 | public MVWorldListener(MultiverseCore plugin) { 27 | this.plugin = plugin; 28 | this.worldManager = plugin.getMVWorldManager(); 29 | } 30 | 31 | /** 32 | * This method is called when Bukkit fires off a WorldUnloadEvent. 33 | * @param event The Event that was fired. 34 | */ 35 | @EventHandler 36 | public void unloadWorld(WorldUnloadEvent event) { 37 | if (event.isCancelled()) { 38 | return; 39 | } 40 | if (event.getWorld() instanceof World) { 41 | World world = (World) event.getWorld(); 42 | if (world != null) { 43 | this.plugin.getMVWorldManager().unloadWorld(world.getName(), false); 44 | } 45 | } 46 | } 47 | 48 | /** 49 | * This method is called when Bukkit fires off a WorldLoadEvent. 50 | * @param event The Event that was fired. 51 | */ 52 | @EventHandler 53 | public void loadWorld(WorldLoadEvent event) { 54 | World world = event.getWorld(); 55 | if (world != null) { 56 | if (this.plugin.getMVWorldManager().getUnloadedWorlds().contains(world.getName())) { 57 | this.plugin.getMVWorldManager().loadWorld(world.getName()); 58 | } 59 | MultiverseWorld mvWorld = plugin.getMVWorldManager().getMVWorld(world); 60 | if (mvWorld != null) { 61 | // This is where we can temporarily fix those pesky property issues! 62 | world.setPVP(mvWorld.isPVPEnabled()); 63 | world.setDifficulty(mvWorld.getDifficulty()); 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/api/SafeTTeleporter.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.api; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.command.CommandSender; 5 | import org.bukkit.entity.Entity; 6 | 7 | import com.onarandombox.MultiverseCore.enums.TeleportResult; 8 | 9 | import java.util.concurrent.CompletableFuture; 10 | 11 | /** 12 | * Used to safely teleport people. 13 | */ 14 | public interface SafeTTeleporter extends Teleporter { 15 | 16 | /** 17 | * Gets the next safe location around the given location. 18 | * @param l A {@link Location}. 19 | * @return A safe {@link Location}. 20 | */ 21 | Location getSafeLocation(Location l); 22 | 23 | /** 24 | * Gets the next safe location around the given location. 25 | * @param l A {@link Location}. 26 | * @param tolerance The tolerance. 27 | * @param radius The radius. 28 | * @return A safe {@link Location}. 29 | */ 30 | Location getSafeLocation(Location l, int tolerance, int radius); 31 | 32 | /** 33 | * Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if 34 | * it's not, will adjust the final destination accordingly. 35 | * 36 | * @param teleporter Person who performed the teleport command. 37 | * @param teleportee Entity to teleport 38 | * @param d Destination to teleport them to 39 | * @return true for success, false for failure 40 | */ 41 | CompletableFuture safelyTeleport(CommandSender teleporter, Entity teleportee, MVDestination d); 42 | 43 | /** 44 | * Safely teleport the entity to the Location. This may perform checks to 45 | * see if the place is safe, and if 46 | * it's not, will adjust the final destination accordingly. 47 | * 48 | * @param teleporter Person who issued the teleport command. 49 | * @param teleportee Entity to teleport. 50 | * @param location Location to teleport them to. 51 | * @param safely Should the destination be checked for safety before teleport? 52 | * @return true for success, false for failure. 53 | */ 54 | TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, Location location, 55 | boolean safely); 56 | 57 | /** 58 | * Returns a safe location for the entity to spawn at. 59 | * 60 | * @param e The entity to spawn 61 | * @param d The MVDestination to take the entity to. 62 | * @return A new location to spawn the entity at. 63 | */ 64 | CompletableFuture getSafeLocation(Entity e, MVDestination d); 65 | 66 | /** 67 | * Finds a portal-block next to the specified {@link Location}. 68 | * @param l The {@link Location} 69 | * @return The next portal-block's {@link Location}. 70 | */ 71 | Location findPortalBlockNextTo(Location l); 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/destination/InvalidDestination.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.destination; 9 | 10 | import com.onarandombox.MultiverseCore.api.MVDestination; 11 | import org.bukkit.ChatColor; 12 | import org.bukkit.Location; 13 | import org.bukkit.entity.Entity; 14 | import org.bukkit.plugin.java.JavaPlugin; 15 | import org.bukkit.util.Vector; 16 | 17 | /** 18 | * An invalid {@link MVDestination}. 19 | */ 20 | public class InvalidDestination implements MVDestination { 21 | 22 | /** 23 | * {@inheritDoc} 24 | */ 25 | @Override 26 | public String getIdentifier() { 27 | return "i"; 28 | } 29 | 30 | /** 31 | * {@inheritDoc} 32 | */ 33 | @Override 34 | public boolean isThisType(JavaPlugin plugin, String destination) { 35 | return false; 36 | } 37 | 38 | /** 39 | * {@inheritDoc} 40 | */ 41 | @Override 42 | public Location getLocation(Entity e) { 43 | return null; 44 | } 45 | 46 | /** 47 | * {@inheritDoc} 48 | */ 49 | @Override 50 | public boolean isValid() { 51 | return false; 52 | } 53 | 54 | /** 55 | * {@inheritDoc} 56 | */ 57 | @Override 58 | public void setDestination(JavaPlugin plugin, String destination) { 59 | // Nothing needed, it's invalid. 60 | } 61 | 62 | /** 63 | * {@inheritDoc} 64 | */ 65 | @Override 66 | public String getType() { 67 | return ChatColor.RED + "Invalid Destination"; 68 | } 69 | 70 | /** 71 | * {@inheritDoc} 72 | */ 73 | @Override 74 | public String getName() { 75 | return ChatColor.RED + "Invalid Destination"; 76 | } 77 | 78 | @Override 79 | public String toString() { 80 | return "i:Invalid Destination"; 81 | } 82 | 83 | /** 84 | * {@inheritDoc} 85 | */ 86 | @Override 87 | public String getRequiredPermission() { 88 | return null; 89 | } 90 | 91 | /** 92 | * {@inheritDoc} 93 | */ 94 | @Override 95 | public Vector getVelocity() { 96 | return new Vector(0, 0, 0); 97 | } 98 | 99 | /** 100 | * {@inheritDoc} 101 | */ 102 | @Override 103 | public boolean useSafeTeleporter() { 104 | return false; 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/display/DisplayHandler.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.display; 2 | 3 | import com.google.common.base.Strings; 4 | import org.bukkit.ChatColor; 5 | import org.bukkit.command.CommandSender; 6 | import org.jetbrains.annotations.NotNull; 7 | 8 | import java.util.Collection; 9 | 10 | /** 11 | * Handles the formatting and sending of all content by the {@link ContentDisplay}. 12 | * 13 | * @param Type of content to display. 14 | */ 15 | @FunctionalInterface 16 | public interface DisplayHandler { 17 | 18 | /** 19 | * Formats the raw content into a {@link Collection} for displaying to the given sender. 20 | * 21 | * @param sender The {@link CommandSender} who will the content will be displayed to. 22 | * @param display The responsible {@link ContentDisplay}. 23 | * @return The formatted content. 24 | * @throws DisplayFormatException Issue occurred while formatting content. E.g. invalid page. 25 | */ 26 | Collection format(@NotNull CommandSender sender, @NotNull ContentDisplay display) 27 | throws DisplayFormatException; 28 | 29 | /** 30 | * Sends the header. 31 | * 32 | * @param sender The {@link CommandSender} who will the header will be displayed to. 33 | * @param display The responsible {@link ContentDisplay}. 34 | */ 35 | default void sendHeader(@NotNull CommandSender sender, @NotNull ContentDisplay display) { 36 | if (!Strings.isNullOrEmpty(display.getHeader())) { 37 | sender.sendMessage(display.getHeader()); 38 | } 39 | } 40 | 41 | /** 42 | * Sends info such as filter and page. 43 | * 44 | * @param sender The {@link CommandSender} who will the sub header will be displayed to. 45 | * @param display The responsible {@link ContentDisplay}. 46 | */ 47 | default void sendSubHeader(@NotNull CommandSender sender, @NotNull ContentDisplay display) { 48 | if (display.getFilter().hasFilter()) { 49 | sender.sendMessage(String.format("%s[ %s ]", ChatColor.GRAY, display.getFilter().getFormattedString())); 50 | } 51 | } 52 | 53 | /** 54 | * Sends the content. 55 | * 56 | * @param sender The {@link CommandSender} who will the body will be displayed to. 57 | * @param display The responsible {@link ContentDisplay}. 58 | * @param formattedContent The content after being formatted by {@link #format(CommandSender, ContentDisplay)} 59 | */ 60 | default void sendBody(@NotNull CommandSender sender, @NotNull ContentDisplay display, 61 | Collection formattedContent) { 62 | if (formattedContent == null || formattedContent.size() == 0) { 63 | sender.sendMessage(display.getEmptyMessage()); 64 | return; 65 | } 66 | sender.sendMessage(formattedContent.toArray(new String[0])); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/listeners/MultiverseCoreListener.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.listeners; 9 | 10 | import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent; 11 | import com.onarandombox.MultiverseCore.event.MVPlayerTouchedPortalEvent; 12 | import com.onarandombox.MultiverseCore.event.MVRespawnEvent; 13 | import com.onarandombox.MultiverseCore.event.MVTeleportEvent; 14 | import com.onarandombox.MultiverseCore.event.MVVersionEvent; 15 | import com.onarandombox.MultiverseCore.event.MVWorldDeleteEvent; 16 | import com.onarandombox.MultiverseCore.event.MVWorldPropertyChangeEvent; 17 | import org.bukkit.event.EventHandler; 18 | import org.bukkit.event.Listener; 19 | 20 | /** 21 | * Subclasses of this listener can be used to conveniently listen to MultiverseCore-events. 22 | */ 23 | public abstract class MultiverseCoreListener implements Listener { 24 | /** 25 | * Called when a {@link MVWorldPropertyChangeEvent} is fired. 26 | * @param event The event. 27 | */ 28 | @EventHandler 29 | public void worldPropertyChange(MVWorldPropertyChangeEvent event) { 30 | } 31 | 32 | /** 33 | * Called when a {@link MVWorldDeleteEvent} is fired. 34 | * @param event The event. 35 | */ 36 | @EventHandler 37 | public void worldDelete(MVWorldDeleteEvent event) { 38 | } 39 | 40 | /** 41 | * Called when a {@link MVVersionEvent} is fired. 42 | * @param event The event. 43 | */ 44 | @EventHandler 45 | public void versionRequest(MVVersionEvent event) { 46 | } 47 | 48 | /** 49 | * Called when a {@link MVTeleportEvent} is fired. 50 | * @param event The event. 51 | */ 52 | @EventHandler 53 | public void playerTeleport(MVTeleportEvent event) { 54 | } 55 | 56 | /** 57 | * Called when a {@link MVRespawnEvent} is fired. 58 | * @param event The event. 59 | */ 60 | @EventHandler 61 | public void playerRespawn(MVRespawnEvent event) { 62 | } 63 | 64 | /** 65 | * Called when a {@link MVPlayerTouchedPortalEvent} is fired. 66 | * @param event The event. 67 | */ 68 | @EventHandler 69 | public void playerTouchedPortal(MVPlayerTouchedPortalEvent event) { 70 | } 71 | 72 | /** 73 | * Called when a {@link MVConfigReloadEvent} is fired. 74 | * @param event The event. 75 | */ 76 | @EventHandler 77 | public void configReload(MVConfigReloadEvent event) { 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/VaultHandler.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils; 2 | 3 | import com.dumptruckman.minecraft.util.Logging; 4 | import net.milkbowl.vault.economy.Economy; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.Listener; 8 | import org.bukkit.event.server.PluginDisableEvent; 9 | import org.bukkit.event.server.PluginEnableEvent; 10 | import org.bukkit.plugin.Plugin; 11 | import org.bukkit.plugin.RegisteredServiceProvider; 12 | 13 | /** 14 | * A class we use to interface with Vault when it is present. 15 | */ 16 | public class VaultHandler implements Listener { 17 | 18 | private Economy economy; 19 | 20 | public VaultHandler(final Plugin plugin) { 21 | Bukkit.getPluginManager().registerEvents(new VaultListener(), plugin); 22 | setupVaultEconomy(); 23 | } 24 | 25 | private boolean setupVaultEconomy() { 26 | if (Bukkit.getPluginManager().getPlugin("Vault") != null) { 27 | final RegisteredServiceProvider economyProvider = 28 | Bukkit.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); 29 | if (economyProvider != null) { 30 | Logging.fine("Vault economy enabled."); 31 | economy = economyProvider.getProvider(); 32 | } else { 33 | Logging.finer("Vault economy not detected."); 34 | economy = null; 35 | } 36 | } else { 37 | Logging.finer("Vault was not found."); 38 | economy = null; 39 | } 40 | 41 | return (economy != null); 42 | } 43 | 44 | /** 45 | * Listens for Vault plugin events. 46 | */ 47 | private class VaultListener implements Listener { 48 | @EventHandler 49 | private void vaultEnabled(PluginEnableEvent event) { 50 | if (event.getPlugin() != null && event.getPlugin().getName().equals("Vault")) { 51 | setupVaultEconomy(); 52 | } 53 | } 54 | 55 | @EventHandler 56 | private void vaultDisabled(PluginDisableEvent event) { 57 | if (event.getPlugin() != null && event.getPlugin().getName().equals("Vault")) { 58 | Logging.fine("Vault economy disabled"); 59 | economy = null; 60 | } 61 | } 62 | } 63 | 64 | /** 65 | * Checks whether Vault is in use and has an economy system enabled. 66 | * 67 | * @return true if vault is in use and has an economy system enabled. 68 | */ 69 | public boolean hasEconomy() { 70 | return economy != null; 71 | } 72 | 73 | /** 74 | * Returns the Vault economy system if Vault is present and has an economy system enabled. 75 | * 76 | * @return The vault economy system or null if not configured. 77 | */ 78 | public Economy getEconomy() { 79 | return economy; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/event/MVPlayerTouchedPortalEvent.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.event; 9 | 10 | import org.bukkit.Location; 11 | import org.bukkit.entity.Player; 12 | import org.bukkit.event.Cancellable; 13 | import org.bukkit.event.Event; 14 | import org.bukkit.event.HandlerList; 15 | 16 | /** 17 | * This event is thrown when a portal is touched. 18 | */ 19 | public class MVPlayerTouchedPortalEvent extends Event implements Cancellable { 20 | private Player p; 21 | private Location l; 22 | private boolean isCancelled; 23 | private boolean canUse = true; 24 | 25 | public MVPlayerTouchedPortalEvent(Player p, Location l) { 26 | this.p = p; 27 | this.l = l; 28 | } 29 | 30 | private static final HandlerList HANDLERS = new HandlerList(); 31 | 32 | /** 33 | * {@inheritDoc} 34 | */ 35 | @Override 36 | public HandlerList getHandlers() { 37 | return HANDLERS; 38 | } 39 | 40 | /** 41 | * Gets the handler list. This is required by the event system. 42 | * @return A list of HANDLERS. 43 | */ 44 | public static HandlerList getHandlerList() { 45 | return HANDLERS; 46 | } 47 | 48 | /** 49 | * Gets the {@link Location} of the portal-block that was touched. 50 | * @return The {@link Location} of the portal-block that was touched. 51 | */ 52 | public Location getBlockTouched() { 53 | return this.l; 54 | } 55 | 56 | /** 57 | * Gets the {@link Player} that's touching the portal. 58 | * @return The {@link Player} that's touching the portal. 59 | */ 60 | public Player getPlayer() { 61 | return this.p; 62 | } 63 | 64 | /** 65 | * Gets whether or not the player in this event can use this portal. 66 | * 67 | * @return True if the player can use this portal. 68 | */ 69 | public boolean canUseThisPortal() { 70 | return this.canUse; 71 | } 72 | 73 | /** 74 | * Sets whether or not the player in this event can use this portal. 75 | *

76 | * Setting this to false will cause the player to bounce back! 77 | * 78 | * @param canUse Whether or not the user can go through this portal. 79 | */ 80 | public void setCanUseThisPortal(boolean canUse) { 81 | this.canUse = canUse; 82 | } 83 | 84 | @Override 85 | public boolean isCancelled() { 86 | return this.isCancelled; 87 | } 88 | 89 | @Override 90 | public void setCancelled(boolean b) { 91 | this.isCancelled = b; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.dumptruckman.minecraft.util.Logging; 11 | import com.onarandombox.MultiverseCore.MultiverseCore; 12 | import org.bukkit.ChatColor; 13 | import org.bukkit.command.CommandSender; 14 | import org.bukkit.permissions.PermissionDefault; 15 | 16 | import java.util.List; 17 | import java.util.logging.Level; 18 | 19 | /** 20 | * Enables debug-information. 21 | */ 22 | public class DebugCommand extends MultiverseCommand { 23 | 24 | public DebugCommand(MultiverseCore plugin) { 25 | super(plugin); 26 | this.setName("Turn Debug on/off?"); 27 | this.setCommandUsage("/mv debug" + ChatColor.GOLD + " [1|2|3|off|silent]"); 28 | this.setArgRange(0, 1); 29 | this.addKey("mv debug"); 30 | this.addKey("mv d"); 31 | this.addKey("mvdebug"); 32 | this.addCommandExample("/mv debug " + ChatColor.GOLD + "2"); 33 | this.setPermission("multiverse.core.debug", "Spams the console a bunch.", PermissionDefault.OP); 34 | } 35 | 36 | @Override 37 | public void runCommand(CommandSender sender, List args) { 38 | if (args.size() == 1) { 39 | if (args.get(0).equalsIgnoreCase("off")) { 40 | plugin.getMVConfig().setGlobalDebug(0); 41 | } else { 42 | try { 43 | int debugLevel = Integer.parseInt(args.get(0)); 44 | if (debugLevel > 3 || debugLevel < 0) { 45 | throw new NumberFormatException(); 46 | } 47 | plugin.getMVConfig().setGlobalDebug(debugLevel); 48 | } catch (NumberFormatException e) { 49 | sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE 50 | + " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)"); 51 | } 52 | } 53 | plugin.saveMVConfigs(); 54 | } 55 | this.displayDebugMode(sender); 56 | } 57 | 58 | private void displayDebugMode(CommandSender sender) { 59 | final int debugLevel = plugin.getMVConfig().getGlobalDebug(); 60 | if (debugLevel == 0) { 61 | sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF"); 62 | } else { 63 | sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + debugLevel); 64 | Logging.fine("Multiverse Debug ENABLED"); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/api/BlockSafety.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.api; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.World; 5 | import org.bukkit.entity.Minecart; 6 | import org.bukkit.entity.Vehicle; 7 | 8 | /** 9 | * Used to get block/location-related information. 10 | */ 11 | public interface BlockSafety { 12 | /** 13 | * This function checks whether the block at the given coordinates are above air or not. 14 | * @param l The {@link Location} of the block. 15 | * @return True if the block at that {@link Location} is above air. 16 | */ 17 | boolean isBlockAboveAir(Location l); 18 | 19 | /** 20 | * Checks if a player can spawn safely at the given coordinates. 21 | * @param world The {@link World}. 22 | * @param x The x-coordinate. 23 | * @param y The y-coordinate. 24 | * @param z The z-coordinate. 25 | * @return True if a player can spawn safely at the given coordinates. 26 | */ 27 | boolean playerCanSpawnHereSafely(World world, double x, double y, double z); 28 | 29 | /** 30 | * This function checks whether the block at the coordinates given is safe or not by checking for Lava/Fire/Air 31 | * etc. This also ensures there is enough space for a player to spawn! 32 | * 33 | * @param l The {@link Location} 34 | * @return Whether the player can spawn safely at the given {@link Location} 35 | */ 36 | boolean playerCanSpawnHereSafely(Location l); 37 | 38 | /** 39 | * Gets a safe bed spawn location OR null if the bed is invalid. 40 | * @param l The location of the bead head (block with the pillow on it). 41 | * @return Safe location around the bed or null if no location was found. 42 | */ 43 | Location getSafeBedSpawn(Location l); 44 | 45 | /** 46 | * Gets the location of the top block at the specified {@link Location}. 47 | * @param l Any {@link Location}. 48 | * @return The {@link Location} of the top-block. 49 | */ 50 | Location getTopBlock(Location l); 51 | 52 | /** 53 | * Gets the location of the top block at the specified {@link Location}. 54 | * @param l Any {@link Location}. 55 | * @return The {@link Location} of the top-block. 56 | */ 57 | Location getBottomBlock(Location l); 58 | 59 | /** 60 | * Checks if an entity would be on track at the specified {@link Location}. 61 | * @param l The {@link Location}. 62 | * @return True if an entity would be on tracks at the specified {@link Location}. 63 | */ 64 | boolean isEntitiyOnTrack(Location l); 65 | 66 | /** 67 | * Checks if the specified {@link Minecart} can spawn safely. 68 | * @param cart The {@link Minecart}. 69 | * @return True if the minecart can spawn safely. 70 | */ 71 | boolean canSpawnCartSafely(Minecart cart); 72 | 73 | /** 74 | * Checks if the specified {@link Vehicle} can spawn safely. 75 | * @param vehicle The {@link Vehicle}. 76 | * @return True if the vehicle can spawn safely. 77 | */ 78 | boolean canSpawnVehicleSafely(Vehicle vehicle); 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/api/WorldPurger.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.api; 2 | 3 | import java.util.List; 4 | 5 | import org.bukkit.command.CommandSender; 6 | import org.bukkit.entity.Entity; 7 | 8 | /** 9 | * Used to remove animals from worlds that don't belong there. 10 | */ 11 | public interface WorldPurger { 12 | /** 13 | * Synchronizes the given worlds with their settings. 14 | * 15 | * @param worlds A list of {@link MultiverseWorld} 16 | */ 17 | void purgeWorlds(List worlds); 18 | 19 | /** 20 | * Convenience method for {@link #purgeWorld(MultiverseWorld, java.util.List, boolean, boolean)} that takes the settings from the world-config. 21 | * 22 | * @param world The {@link MultiverseWorld}. 23 | */ 24 | void purgeWorld(MultiverseWorld world); 25 | 26 | /** 27 | * Clear all animals/monsters that do not belong to a world according to the config. 28 | * 29 | * @param mvworld The {@link MultiverseWorld}. 30 | * @param thingsToKill A {@link List} of animals/monsters to be killed. 31 | * @param negateAnimals Whether the monsters in the list should be negated. 32 | * @param negateMonsters Whether the animals in the list should be negated. 33 | */ 34 | void purgeWorld(MultiverseWorld mvworld, List thingsToKill, boolean negateAnimals, 35 | boolean negateMonsters); 36 | 37 | /** 38 | * Clear all animals/monsters that do not belong to a world according to the config. 39 | * 40 | * @param mvworld The {@link MultiverseWorld}. 41 | * @param thingsToKill A {@link List} of animals/monsters to be killed. 42 | * @param negateAnimals Whether the monsters in the list should be negated. 43 | * @param negateMonsters Whether the animals in the list should be negated. 44 | * @param sender The {@link CommandSender} that initiated the action. He will/should be notified. 45 | */ 46 | void purgeWorld(MultiverseWorld mvworld, List thingsToKill, boolean negateAnimals, 47 | boolean negateMonsters, CommandSender sender); 48 | 49 | /** 50 | * Determines whether the specified creature should be killed. 51 | * 52 | * @param e The creature. 53 | * @param thingsToKill A {@link List} of animals/monsters to be killed. 54 | * @param negateAnimals Whether the monsters in the list should be negated. 55 | * @param negateMonsters Whether the animals in the list should be negated. 56 | * @return {@code true} if the creature should be killed, otherwise {@code false}. 57 | */ 58 | boolean shouldWeKillThisCreature(Entity e, List thingsToKill, boolean negateAnimals, boolean negateMonsters); 59 | 60 | /** 61 | * Determines whether the specified creature should be killed and automatically reads the params from a world object. 62 | * 63 | * @param w The world. 64 | * @param e The creature. 65 | * @return {@code true} if the creature should be killed, otherwise {@code false}. 66 | */ 67 | boolean shouldWeKillThisCreature(MultiverseWorld w, Entity e); 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/CheckCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import com.onarandombox.MultiverseCore.api.MVDestination; 12 | import com.onarandombox.MultiverseCore.destination.InvalidDestination; 13 | import com.onarandombox.MultiverseCore.utils.MVPermissions; 14 | import com.onarandombox.MultiverseCore.utils.PlayerFinder; 15 | import org.bukkit.ChatColor; 16 | import org.bukkit.command.CommandSender; 17 | import org.bukkit.entity.Player; 18 | import org.bukkit.permissions.PermissionDefault; 19 | 20 | import java.util.List; 21 | /** 22 | * Checks to see if a player can go to a destination. 23 | */ 24 | public class CheckCommand extends MultiverseCommand { 25 | 26 | public CheckCommand(MultiverseCore plugin) { 27 | super(plugin); 28 | this.setName("Help you validate your multiverse settings"); 29 | this.setCommandUsage("/mv check " + ChatColor.GREEN + "{PLAYER} {DESTINATION}"); 30 | this.setArgRange(2, 2); 31 | this.addKey("mv check"); 32 | this.addKey("mvcheck"); 33 | this.addCommandExample("/mv check " + ChatColor.GREEN + "fernferret " + ChatColor.LIGHT_PURPLE + "w:MyWorld"); 34 | this.addCommandExample("/mv check " + ChatColor.GREEN + "Rigby90 " + ChatColor.LIGHT_PURPLE + "p:MyPortal"); 35 | this.addCommandExample("/mv check " + ChatColor.GREEN + "lithium3141 " + ChatColor.LIGHT_PURPLE + "ow:WarpName"); 36 | this.setPermission("multiverse.core.debug", "Checks to see if a player can go to a destination. Prints debug if false.", PermissionDefault.OP); 37 | } 38 | 39 | @Override 40 | public void runCommand(CommandSender sender, List args) { 41 | Player p = PlayerFinder.get(args.get(0), sender); 42 | if (p == null) { 43 | sender.sendMessage("Could not find player " + ChatColor.GREEN + args.get(0)); 44 | sender.sendMessage("Are they online?"); 45 | return; 46 | } 47 | MVDestination dest = this.plugin.getDestFactory().getDestination(args.get(1)); 48 | if (dest instanceof InvalidDestination) { 49 | sender.sendMessage(String.format("You asked if '%s' could go to %s%s%s,", 50 | args.get(0), ChatColor.GREEN, args.get(0), ChatColor.WHITE)); 51 | sender.sendMessage("but I couldn't find a Destination of that name? Did you type it correctly?"); 52 | return; 53 | } 54 | 55 | MVPermissions perms = this.plugin.getMVPerms(); 56 | perms.tellMeWhyICantDoThis(sender, p, dest); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/PasteGGPasteService.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils.webpaste; 2 | 3 | import org.json.simple.JSONArray; 4 | import org.json.simple.JSONObject; 5 | import org.json.simple.parser.JSONParser; 6 | import org.json.simple.parser.ParseException; 7 | 8 | import java.io.IOException; 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | /** 13 | * Pastes to {@code paste.gg}. 14 | */ 15 | class PasteGGPasteService extends PasteService { 16 | private final boolean isPrivate; 17 | private static final String PASTEGG_POST_REQUEST = "https://api.paste.gg/v1/pastes"; 18 | 19 | PasteGGPasteService(boolean isPrivate) { 20 | super(PASTEGG_POST_REQUEST); 21 | this.isPrivate = isPrivate; 22 | } 23 | 24 | /** 25 | * {@inheritDoc} 26 | */ 27 | @Override 28 | String encodeData(String data) { 29 | Map mapData = new HashMap(); 30 | mapData.put("multiverse.txt", data); 31 | return this.encodeData(mapData); 32 | } 33 | 34 | /** 35 | * {@inheritDoc} 36 | */ 37 | @Override 38 | String encodeData(Map files) { 39 | JSONObject root = new JSONObject(); 40 | root.put("name", "Multiverse-Core Debug Info"); 41 | root.put("visibility", this.isPrivate ? "unlisted" : "public"); 42 | JSONArray fileList = new JSONArray(); 43 | for (Map.Entry entry : files.entrySet()) { 44 | JSONObject fileObject = new JSONObject(); 45 | JSONObject contentObject = new JSONObject(); 46 | fileObject.put("name", entry.getKey()); 47 | fileObject.put("content", contentObject); 48 | contentObject.put("format", "text"); 49 | contentObject.put("value", entry.getValue()); 50 | fileList.add(fileObject); 51 | } 52 | 53 | root.put("files", fileList); 54 | return root.toJSONString(); 55 | } 56 | 57 | /** 58 | * {@inheritDoc} 59 | */ 60 | @Override 61 | public String postData(String data) throws PasteFailedException { 62 | try { 63 | String stringJSON = this.exec(encodeData(data), ContentType.JSON); 64 | return (String) ((JSONObject) ((JSONObject) new JSONParser().parse(stringJSON)).get("result")).get("id"); 65 | } catch (IOException | ParseException e) { 66 | throw new PasteFailedException(e); 67 | } 68 | } 69 | 70 | /** 71 | * {@inheritDoc} 72 | */ 73 | @Override 74 | public String postData(Map data) throws PasteFailedException { 75 | try { 76 | String stringJSON = this.exec(encodeData(data), ContentType.JSON); 77 | return "https://paste.gg/" + ((JSONObject) ((JSONObject) new JSONParser().parse(stringJSON)).get("result")).get("id"); 78 | } catch (IOException | ParseException e) { 79 | throw new PasteFailedException(e); 80 | } 81 | } 82 | 83 | /** 84 | * {@inheritDoc} 85 | */ 86 | @Override 87 | public boolean supportsMultiFile() { 88 | return true; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/webpaste/GitHubPasteService.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils.webpaste; 2 | 3 | import org.json.simple.JSONObject; 4 | import org.json.simple.parser.JSONParser; 5 | import org.json.simple.parser.ParseException; 6 | 7 | import java.io.IOException; 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | /** 12 | * Pastes to {@code gist.github.com}. Requires an access token with the {@code gist} scope. 13 | */ 14 | class GitHubPasteService extends PasteService { 15 | private final boolean isPrivate; 16 | // this access token must have the "gist" scope 17 | private static final String ACCESS_TOKEN = "token github-access-token"; 18 | private static final String GITHUB_POST_REQUEST = "https://api.github.com/gists"; 19 | 20 | GitHubPasteService(boolean isPrivate) { 21 | super(GITHUB_POST_REQUEST, ACCESS_TOKEN); 22 | this.isPrivate = isPrivate; 23 | if (ACCESS_TOKEN.endsWith("access-token")) { 24 | throw new UnsupportedOperationException(); 25 | } 26 | } 27 | 28 | /** 29 | * {@inheritDoc} 30 | */ 31 | @Override 32 | String encodeData(String data) { 33 | Map mapData = new HashMap(); 34 | mapData.put("multiverse.txt", data); 35 | return this.encodeData(mapData); 36 | } 37 | 38 | /** 39 | * {@inheritDoc} 40 | */ 41 | @Override 42 | String encodeData(Map files) { 43 | JSONObject root = new JSONObject(); 44 | root.put("description", "Multiverse-Core Debug Info"); 45 | root.put("public", !this.isPrivate); 46 | JSONObject fileList = new JSONObject(); 47 | for (Map.Entry entry : files.entrySet()) { 48 | JSONObject fileObject = new JSONObject(); 49 | fileObject.put("content", entry.getValue()); 50 | fileList.put(entry.getKey(), fileObject); 51 | } 52 | 53 | root.put("files", fileList); 54 | return root.toJSONString(); 55 | } 56 | 57 | /** 58 | * {@inheritDoc} 59 | */ 60 | @Override 61 | public String postData(String data) throws PasteFailedException { 62 | try { 63 | String stringJSON = this.exec(encodeData(data), ContentType.JSON); 64 | return (String) ((JSONObject) new JSONParser().parse(stringJSON)).get("html_url"); 65 | } catch (IOException | ParseException e) { 66 | throw new PasteFailedException(e); 67 | } 68 | } 69 | 70 | /** 71 | * {@inheritDoc} 72 | */ 73 | @Override 74 | public String postData(Map data) throws PasteFailedException { 75 | try { 76 | String stringJSON = this.exec(encodeData(data), ContentType.JSON); 77 | return (String) ((JSONObject) new JSONParser().parse(stringJSON)).get("html_url"); 78 | } catch (IOException | ParseException e) { 79 | throw new PasteFailedException(e); 80 | } 81 | } 82 | 83 | /** 84 | * {@inheritDoc} 85 | */ 86 | @Override 87 | public boolean supportsMultiFile() { 88 | return true; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/enums/EnglishChatColor.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.enums; 9 | 10 | import org.bukkit.ChatColor; 11 | 12 | /** 13 | * A regular {@link ChatColor} represented by an english string. 14 | * @see ChatColor 15 | */ 16 | public enum EnglishChatColor { 17 | // BEGIN CHECKSTYLE-SUPPRESSION: JavadocVariable 18 | AQUA(ChatColor.AQUA), 19 | BLACK(ChatColor.BLACK), 20 | BLUE(ChatColor.BLUE), 21 | DARKAQUA(ChatColor.DARK_AQUA), 22 | DARKBLUE(ChatColor.DARK_BLUE), 23 | DARKGRAY(ChatColor.DARK_GRAY), 24 | DARKGREEN(ChatColor.DARK_GREEN), 25 | DARKPURPLE(ChatColor.DARK_PURPLE), 26 | DARKRED(ChatColor.DARK_RED), 27 | GOLD(ChatColor.GOLD), 28 | GRAY(ChatColor.GRAY), 29 | GREEN(ChatColor.GREEN), 30 | LIGHTPURPLE(ChatColor.LIGHT_PURPLE), 31 | RED(ChatColor.RED), 32 | YELLOW(ChatColor.YELLOW), 33 | WHITE(ChatColor.WHITE); 34 | // END CHECKSTYLE-SUPPRESSION: JavadocVariable 35 | 36 | private final ChatColor color; 37 | //private final String text; 38 | 39 | EnglishChatColor(ChatColor color) { 40 | this.color = color; 41 | } 42 | 43 | /** 44 | * Gets the text. 45 | * @return The text. 46 | */ 47 | public String getText() { 48 | return this.name(); 49 | } 50 | 51 | /** 52 | * Gets the color. 53 | * @return The color as {@link ChatColor}. 54 | */ 55 | public ChatColor getColor() { 56 | return this.color; 57 | } 58 | 59 | /** 60 | * Constructs a string containing all available colors. 61 | * @return That {@link String}. 62 | */ 63 | public static String getAllColors() { 64 | String buffer = ""; 65 | for (EnglishChatColor c : EnglishChatColor.values()) { 66 | buffer += c.getColor() + c.getText() + " "; 67 | } 68 | return buffer; 69 | } 70 | 71 | /** 72 | * Constructs an {@link EnglishChatColor} from a {@link String}. 73 | * @param text The {@link String}. 74 | * @return The {@link EnglishChatColor}. 75 | */ 76 | public static EnglishChatColor fromString(String text) { 77 | if (text != null) { 78 | for (EnglishChatColor c : EnglishChatColor.values()) { 79 | if (text.equalsIgnoreCase(c.name())) { 80 | return c; 81 | } 82 | } 83 | } 84 | return null; 85 | } 86 | 87 | /** 88 | * Looks if the given-color name is a valid color. 89 | * @param aliasColor A color-name. 90 | * @return True if the name is a valid color, false if it isn't. 91 | */ 92 | public static boolean isValidAliasColor(String aliasColor) { 93 | return (EnglishChatColor.fromString(aliasColor) != null); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/MVMessaging.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.utils; 9 | 10 | import org.bukkit.command.CommandSender; 11 | import org.bukkit.entity.Player; 12 | 13 | import com.onarandombox.MultiverseCore.api.MultiverseMessaging; 14 | 15 | import java.util.Collection; 16 | import java.util.HashMap; 17 | import java.util.Map; 18 | 19 | /** 20 | * The default-implementation of {@link MultiverseMessaging}. 21 | */ 22 | public class MVMessaging implements MultiverseMessaging { 23 | private Map sentList; 24 | private int cooldown; 25 | 26 | public MVMessaging() { 27 | this.sentList = new HashMap(); 28 | this.cooldown = 5000; // SUPPRESS CHECKSTYLE: MagicNumberCheck 29 | } 30 | 31 | /** 32 | * {@inheritDoc} 33 | */ 34 | @Override 35 | public void setCooldown(int milliseconds) { 36 | this.cooldown = milliseconds; 37 | } 38 | 39 | /** 40 | * {@inheritDoc} 41 | */ 42 | @Override 43 | public boolean sendMessage(CommandSender sender, String message, boolean ignoreCooldown) { 44 | return this.sendMessages(sender, new String[]{ message }, ignoreCooldown); 45 | } 46 | 47 | /** 48 | * {@inheritDoc} 49 | */ 50 | @Override 51 | public boolean sendMessages(CommandSender sender, String[] messages, boolean ignoreCooldown) { 52 | if (!(sender instanceof Player) || ignoreCooldown) { 53 | 54 | sendMessages(sender, messages); 55 | return true; 56 | } 57 | if (!this.sentList.containsKey(sender.getName())) { 58 | sendMessages(sender, messages); 59 | this.sentList.put(sender.getName(), System.currentTimeMillis()); 60 | return true; 61 | } else { 62 | long time = System.currentTimeMillis(); 63 | if (time >= this.sentList.get(sender.getName()) + this.cooldown) { 64 | sendMessages(sender, messages); 65 | this.sentList.put(sender.getName(), System.currentTimeMillis()); 66 | return true; 67 | } 68 | } 69 | return false; 70 | } 71 | 72 | /** 73 | * {@inheritDoc} 74 | */ 75 | @Override 76 | public boolean sendMessages(CommandSender sender, Collection messages, boolean ignoreCooldown) { 77 | return this.sendMessages(sender, messages.toArray(new String[0]), ignoreCooldown); 78 | } 79 | 80 | private static void sendMessages(CommandSender sender, String[] messages) { 81 | for (String s : messages) { 82 | sender.sendMessage(s); 83 | } 84 | } 85 | 86 | /** 87 | * {@inheritDoc} 88 | */ 89 | @Override 90 | public int getCooldown() { 91 | return cooldown; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commandtools/queue/QueuedCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2020. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commandtools.queue; 9 | 10 | import org.bukkit.command.CommandSender; 11 | import org.bukkit.scheduler.BukkitTask; 12 | import org.jetbrains.annotations.NotNull; 13 | 14 | /** 15 | * Represents a single command used in {@link CommandQueueManager} for confirming before running potentially 16 | * dangerous action. 17 | */ 18 | public class QueuedCommand { 19 | 20 | private static final String DEFAULT_PROMPT_MESSAGE = "The command you are trying to run is deemed dangerous."; 21 | private static final int DEFAULT_VALID_TIME = 10; 22 | 23 | private final CommandSender sender; 24 | private final Runnable action; 25 | private final String prompt; 26 | private final int validDuration; 27 | private BukkitTask expireTask; 28 | 29 | public QueuedCommand(CommandSender sender, Runnable action) { 30 | this(sender, action, DEFAULT_PROMPT_MESSAGE, DEFAULT_VALID_TIME); 31 | } 32 | 33 | public QueuedCommand(CommandSender sender, Runnable action, String prompt) { 34 | this(sender, action, prompt, DEFAULT_VALID_TIME); 35 | } 36 | 37 | public QueuedCommand(CommandSender sender, Runnable action, int validDuration) { 38 | this(sender, action, DEFAULT_PROMPT_MESSAGE, validDuration); 39 | } 40 | 41 | /** 42 | * Creates a new queue command, to be registered at {@link CommandQueueManager#addToQueue(QueuedCommand)}. 43 | * 44 | * @param sender The sender that ran the command needed for confirmation. 45 | * @param action The logic to execute upon confirming. 46 | * @param prompt Question to ask sender to confirm. 47 | * @param validDuration Duration in which the command is valid for confirm in seconds. 48 | */ 49 | public QueuedCommand(CommandSender sender, Runnable action, String prompt, int validDuration) { 50 | this.sender = sender; 51 | this.action = action; 52 | this.prompt = prompt; 53 | this.validDuration = validDuration; 54 | } 55 | 56 | @NotNull 57 | CommandSender getSender() { 58 | return sender; 59 | } 60 | 61 | @NotNull 62 | String getPrompt() { 63 | return prompt; 64 | } 65 | 66 | int getValidDuration() { 67 | return validDuration; 68 | } 69 | 70 | @NotNull 71 | Runnable getAction() { 72 | return action; 73 | } 74 | 75 | @NotNull 76 | BukkitTask getExpireTask() { 77 | return expireTask; 78 | } 79 | 80 | void setExpireTask(@NotNull BukkitTask expireTask) { 81 | if (this.expireTask != null) { 82 | throw new IllegalStateException("This queue command already has an expire task. You can't register twice!"); 83 | } 84 | this.expireTask = expireTask; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/api/LocationManipulation.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.api; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.entity.Vehicle; 5 | import org.bukkit.util.Vector; 6 | 7 | /** 8 | * Used to manipulate locations. 9 | */ 10 | public interface LocationManipulation { 11 | /** 12 | * Convert a Location into a Colon separated string to allow us to store it in text. 13 | *

14 | * WORLD:X,Y,Z:yaw:pitch 15 | *

16 | * The corresponding String2Loc function is {@link #stringToLocation} 17 | * 18 | * @param location The Location to save. 19 | * @return The location as a string in this format: WORLD:x,y,z:yaw:pitch 20 | */ 21 | String locationToString(Location location); 22 | 23 | /** 24 | * This method simply does some rounding, rather than forcing a call to the server to get the blockdata. 25 | * 26 | * @param l The location to round to the block location 27 | * @return A rounded location. 28 | */ 29 | Location getBlockLocation(Location l); 30 | 31 | /** 32 | * Returns a new location from a given string. The format is as follows: 33 | *

34 | * WORLD:X,Y,Z:yaw:pitch 35 | *

36 | * The corresponding Location2String function is {@link #stringToLocation} 37 | * 38 | * @param locationString The location represented as a string (WORLD:X,Y,Z:yaw:pitch) 39 | * @return A new location defined by the string or null if the string was invalid. 40 | */ 41 | Location stringToLocation(String locationString); 42 | 43 | /** 44 | * Returns a colored string with the coords. 45 | * 46 | * @param l The {@link Location} 47 | * @return The {@link String} 48 | */ 49 | String strCoords(Location l); 50 | 51 | /** 52 | * Converts a location to a printable readable formatted string including pitch/yaw. 53 | * 54 | * @param l The {@link Location} 55 | * @return The {@link String} 56 | */ 57 | String strCoordsRaw(Location l); 58 | 59 | /** 60 | * Return the NESW Direction a Location is facing. 61 | * 62 | * @param location The {@link Location} 63 | * @return The NESW Direction 64 | */ 65 | String getDirection(Location location); 66 | 67 | /** 68 | * Returns the float yaw position for the given cardinal direction. 69 | * 70 | * @param orientation The cardinal direction 71 | * @return The yaw 72 | */ 73 | float getYaw(String orientation); 74 | 75 | /** 76 | * Returns a speed float from a given vector. 77 | * 78 | * @param v The {@link Vector} 79 | * @return The speed 80 | */ 81 | float getSpeed(Vector v); 82 | 83 | /** 84 | * Returns a translated vector from the given direction. 85 | * 86 | * @param v The old {@link Vector} 87 | * @param direction The new direction 88 | * @return The translated {@link Vector} 89 | */ 90 | Vector getTranslatedVector(Vector v, String direction); 91 | 92 | /** 93 | * Returns the next Location that a {@link Vehicle} is traveling at. 94 | * 95 | * @param v The {@link Vehicle} 96 | * @return The {@link Location} 97 | */ 98 | Location getNextBlock(Vehicle v); 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/ModifyCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import com.onarandombox.MultiverseCore.enums.Action; 12 | import com.onarandombox.MultiverseCore.enums.AddProperties; 13 | import org.bukkit.ChatColor; 14 | import org.bukkit.command.CommandSender; 15 | import org.bukkit.permissions.Permission; 16 | import org.bukkit.permissions.PermissionDefault; 17 | 18 | import java.util.HashMap; 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | /** 23 | * Used to modify various aspects of worlds. 24 | */ 25 | public class ModifyCommand extends MultiverseCommand { 26 | 27 | public ModifyCommand(MultiverseCore plugin) { 28 | super(plugin); 29 | this.setName("Modify a World"); 30 | this.setCommandUsage("/mv modify" + ChatColor.GREEN + " {set|add|remove|clear} ..."); 31 | this.setArgRange(2, 3); 32 | this.addKey("mvm"); 33 | this.addKey("mvmodify"); 34 | this.addKey("mv modify"); 35 | Map children = new HashMap(); 36 | children.put("multiverse.core.modify.add", true); 37 | children.put("multiverse.core.modify.modify", true); 38 | children.put("multiverse.core.modify.clear", true); 39 | children.put("multiverse.core.modify.remove", true); 40 | Permission modify = new Permission("multiverse.core.modify", 41 | "Modify various aspects of worlds. It requires add/set/clear/remove. See the examples below", PermissionDefault.OP, children); 42 | this.addCommandExample(ChatColor.AQUA + "/mv modify set ?"); 43 | this.addCommandExample(ChatColor.GREEN + "/mv modify add ?"); 44 | this.addCommandExample(ChatColor.BLUE + "/mv modify clear ?"); 45 | this.addCommandExample(ChatColor.RED + "/mv modify remove ?"); 46 | this.setPermission(modify); 47 | } 48 | 49 | /** 50 | * Validates the specified action. 51 | * 52 | * @param action The {@link Action}. 53 | * @param property The property. 54 | * @return Whether this action is valid. 55 | */ 56 | protected static boolean validateAction(Action action, String property) { 57 | if (action != Action.Set) { 58 | try { 59 | AddProperties.valueOf(property); 60 | return true; 61 | } catch (IllegalArgumentException e) { 62 | return false; 63 | } 64 | } 65 | return false; 66 | } 67 | 68 | @Override 69 | public void runCommand(CommandSender sender, List args) { 70 | // This is just a place holder. The real commands are in: 71 | // ModifyAddCommand 72 | // ModifyRemoveCommand 73 | // ModifySetCommand 74 | // ModifyClearCommand 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/configuration/SpawnLocation.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.configuration; 2 | 3 | import java.lang.ref.Reference; 4 | import java.lang.ref.WeakReference; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import org.bukkit.Chunk; 9 | import org.bukkit.Location; 10 | import org.bukkit.World; 11 | import org.bukkit.block.Block; 12 | import org.bukkit.configuration.serialization.ConfigurationSerializable; 13 | import org.bukkit.configuration.serialization.SerializableAs; 14 | 15 | /** 16 | * Just like a regular {@link Location}, however {@code world} is usually {@code null} 17 | * or just a weak reference and it implements {@link ConfigurationSerializable}. 18 | */ 19 | @SerializableAs("MVSpawnLocation") 20 | public class SpawnLocation extends Location implements ConfigurationSerializable { 21 | private Reference worldRef; 22 | 23 | public SpawnLocation(double x, double y, double z) { 24 | super(null, x, y, z); 25 | } 26 | 27 | public SpawnLocation(double x, double y, double z, float yaw, float pitch) { 28 | super(null, x, y, z, yaw, pitch); 29 | } 30 | 31 | public SpawnLocation(Location loc) { 32 | this(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); 33 | } 34 | 35 | /** 36 | * {@inheritDoc} 37 | */ 38 | @Override 39 | public World getWorld() { 40 | return (this.worldRef != null) ? this.worldRef.get() : null; 41 | } 42 | 43 | /** 44 | * {@inheritDoc} 45 | */ 46 | @Override 47 | public void setWorld(World world) { 48 | this.worldRef = new WeakReference(world); 49 | } 50 | 51 | /** 52 | * {@inheritDoc} 53 | */ 54 | @Override 55 | public Chunk getChunk() { 56 | if ((this.worldRef != null) && (this.worldRef.get() != null)) 57 | return this.worldRef.get().getChunkAt(this); 58 | return null; 59 | } 60 | 61 | /** 62 | * {@inheritDoc} 63 | */ 64 | @Override 65 | public Block getBlock() { 66 | if ((this.worldRef != null) && (this.worldRef.get() != null)) 67 | return this.worldRef.get().getBlockAt(this); 68 | return null; 69 | } 70 | 71 | /** 72 | * {@inheritDoc} 73 | */ 74 | @Override 75 | public Map serialize() { 76 | Map serialized = new HashMap(5); // SUPPRESS CHECKSTYLE: MagicNumberCheck 77 | serialized.put("x", this.getX()); 78 | serialized.put("y", this.getY()); 79 | serialized.put("z", this.getZ()); 80 | serialized.put("pitch", this.getPitch()); 81 | serialized.put("yaw", this.getYaw()); 82 | return serialized; 83 | } 84 | 85 | /** 86 | * Let Bukkit be able to deserialize this. 87 | * @param args The map. 88 | * @return The deserialized object. 89 | */ 90 | public static SpawnLocation deserialize(Map args) { 91 | double x = ((Number) args.get("x")).doubleValue(); 92 | double y = ((Number) args.get("y")).doubleValue(); 93 | double z = ((Number) args.get("z")).doubleValue(); 94 | float pitch = ((Number) args.get("pitch")).floatValue(); 95 | float yaw = ((Number) args.get("yaw")).floatValue(); 96 | return new SpawnLocation(x, y, z, yaw, pitch); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.yml: -------------------------------------------------------------------------------- 1 | name: 🐛 Report a Bug 2 | description: Report a problem with Multiverse-Core. 3 | title: "[Bug]: " 4 | labels: ["Bug: Unconfirmed"] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thanks for taking the time to fill out this bug report! 10 | 11 | If you are having issues with other submodules of Multiverse, please go to their respective git repo: 12 | Multiverse-Portals: https://github.com/Multiverse/Multiverse-Portals/issues/new/choose 13 | Multiverse-NetherPortals: https://github.com/Multiverse/Multiverse-NetherPortals/issues/new/choose 14 | Multiverse-Inventories: https://github.com/Multiverse/Multiverse-Inventories/issues/new/choose 15 | Multiverse-SignPortals: https://github.com/Multiverse/Multiverse-SignPortals/issues/new/choose 16 | 17 | Not sure if this is a bug with Multiverse-Core? Feel free to ask on our Discord server: https://discord.gg/NZtfKky 18 | 19 | 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. 20 | - type: input 21 | id: mutliverse-version-info 22 | attributes: 23 | label: '`/mv version -p` output' 24 | description: Run `/mv version -p` in the console, then copy and paste the link from the output of the command into this box. 25 | validations: 26 | required: true 27 | - type: input 28 | id: server-logs 29 | attributes: 30 | label: Server logs 31 | description: > 32 | Include full startup log and console error (if any). upload all relevant logs to either https://paste.gg 33 | or https://gist.github.com, save and the paste the link in this box. 34 | validations: 35 | required: true 36 | - type: textarea 37 | id: server-version 38 | attributes: 39 | label: Server Version 40 | description: Output of `/version` command. 41 | placeholder: server version info 42 | render: shell 43 | validations: 44 | required: true 45 | - type: textarea 46 | id: bug-description 47 | attributes: 48 | label: Bug Description 49 | description: Describe in detail what the bug is about. Include the expected behaviour and actual behaviour. 50 | placeholder: "Example: When running `/mv` it cause the server to crash..." 51 | validations: 52 | required: true 53 | - type: textarea 54 | id: reproduce-steps 55 | attributes: 56 | label: Steps to reproduce 57 | description: Provide detailed intructions to trigger the bug. 58 | placeholder: | 59 | Example: 60 | 1. Start a server with only multiverse installed. 61 | 2. Run `/mv` command. 62 | 3. Players all get kicked with a "server closed" message. 63 | ... 64 | validations: 65 | required: true 66 | - type: checkboxes 67 | id: agreements 68 | attributes: 69 | label: Agreements 70 | description: Ensure you have done the following being submitting this issue. 71 | options: 72 | - label: I have searched for and ensured there isn't already an open or resolved issue(s) regarding this. 73 | required: true 74 | - label: > 75 | I was able to reproduce my issue on a freshly setup and up-to-date server with the latest 76 | version of Multiverse plugins with no other plugins and with no kinds of other server or client mods. 77 | required: true 78 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/CoordCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import com.onarandombox.MultiverseCore.api.MVWorldManager; 12 | import com.onarandombox.MultiverseCore.api.MultiverseWorld; 13 | import org.bukkit.ChatColor; 14 | import org.bukkit.Material; 15 | import org.bukkit.World; 16 | import org.bukkit.command.CommandSender; 17 | import org.bukkit.entity.Player; 18 | import org.bukkit.permissions.PermissionDefault; 19 | 20 | import java.text.DecimalFormat; 21 | import java.util.List; 22 | 23 | /** 24 | * Returns detailed information on the Players where abouts. 25 | */ 26 | public class CoordCommand extends MultiverseCommand { 27 | private MVWorldManager worldManager; 28 | 29 | public CoordCommand(MultiverseCore plugin) { 30 | super(plugin); 31 | this.setName("Coordinates"); 32 | this.setCommandUsage("/mv coord"); 33 | this.setArgRange(0, 0); 34 | this.addKey("mv coord"); 35 | this.addKey("mvcoord"); 36 | this.addKey("mvco"); 37 | this.addCommandExample("/mv coord"); 38 | this.setPermission("multiverse.core.coord", "Returns detailed information on the Players where abouts.", PermissionDefault.OP); 39 | this.worldManager = this.plugin.getMVWorldManager(); 40 | } 41 | 42 | @Override 43 | public void runCommand(CommandSender sender, List args) { 44 | // Check if the command was sent from a Player. 45 | if (sender instanceof Player) { 46 | Player p = (Player) sender; 47 | World world = p.getWorld(); 48 | 49 | if (!this.worldManager.isMVWorld(world.getName())) { 50 | this.plugin.showNotMVWorldMessage(sender, world.getName()); 51 | return; 52 | } 53 | 54 | MultiverseWorld mvworld = this.worldManager.getMVWorld(world.getName()); 55 | 56 | p.sendMessage(ChatColor.AQUA + "--- Location Information ---"); 57 | p.sendMessage(ChatColor.AQUA + "World: " + ChatColor.WHITE + world.getName()); 58 | p.sendMessage(ChatColor.AQUA + "Alias: " + mvworld.getColoredWorldString()); 59 | p.sendMessage(ChatColor.AQUA + "World Scale: " + ChatColor.WHITE + mvworld.getScaling()); 60 | DecimalFormat df = new DecimalFormat(); 61 | df.setMinimumFractionDigits(0); 62 | df.setMaximumFractionDigits(2); 63 | p.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + plugin.getLocationManipulation().strCoords(p.getLocation())); 64 | p.sendMessage(ChatColor.AQUA + "Direction: " + ChatColor.WHITE + plugin.getLocationManipulation().getDirection(p.getLocation())); 65 | p.sendMessage(ChatColor.AQUA + "Block: " + ChatColor.WHITE + world.getBlockAt(p.getLocation()).getType()); 66 | } else { 67 | sender.sendMessage("This command needs to be used from a Player."); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commandtools/queue/DummyCommandBlockSender.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.commandtools.queue; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Server; 5 | import org.bukkit.command.CommandSender; 6 | import org.bukkit.permissions.Permission; 7 | import org.bukkit.permissions.PermissionAttachment; 8 | import org.bukkit.permissions.PermissionAttachmentInfo; 9 | import org.bukkit.plugin.Plugin; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.jetbrains.annotations.Nullable; 12 | 13 | import java.util.Set; 14 | 15 | /** 16 | * Used by {@link CommandQueueManager}, so different commands block can be recognised as one. 17 | */ 18 | class DummyCommandBlockSender implements CommandSender { 19 | 20 | @Override 21 | public void sendMessage(@NotNull String message) { 22 | throw new UnsupportedOperationException(); 23 | } 24 | 25 | @Override 26 | public void sendMessage(@NotNull String[] messages) { 27 | throw new UnsupportedOperationException(); 28 | } 29 | 30 | @Override 31 | public @NotNull Server getServer() { 32 | return Bukkit.getServer(); 33 | } 34 | 35 | @Override 36 | public @NotNull String getName() { 37 | return "DummyCommandBlockSender"; 38 | } 39 | 40 | @Override 41 | public boolean isPermissionSet(@NotNull String name) { 42 | throw new UnsupportedOperationException(); 43 | } 44 | 45 | @Override 46 | public boolean isPermissionSet(@NotNull Permission perm) { 47 | throw new UnsupportedOperationException(); 48 | } 49 | 50 | @Override 51 | public boolean hasPermission(@NotNull String name) { 52 | throw new UnsupportedOperationException(); 53 | } 54 | 55 | @Override 56 | public boolean hasPermission(@NotNull Permission perm) { 57 | throw new UnsupportedOperationException(); 58 | } 59 | 60 | @Override 61 | public @NotNull PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) { 62 | throw new UnsupportedOperationException(); 63 | } 64 | 65 | @Override 66 | public @NotNull PermissionAttachment addAttachment(@NotNull Plugin plugin) { 67 | throw new UnsupportedOperationException(); 68 | } 69 | 70 | @Override 71 | public @Nullable PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) { 72 | throw new UnsupportedOperationException(); 73 | } 74 | 75 | @Override 76 | public @Nullable PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) { 77 | throw new UnsupportedOperationException(); 78 | } 79 | 80 | @Override 81 | public void removeAttachment(@NotNull PermissionAttachment attachment) { 82 | throw new UnsupportedOperationException(); 83 | } 84 | 85 | @Override 86 | public void recalculatePermissions() { 87 | throw new UnsupportedOperationException(); 88 | } 89 | 90 | @Override 91 | public @NotNull Set getEffectivePermissions() { 92 | throw new UnsupportedOperationException(); 93 | } 94 | 95 | @Override 96 | public boolean isOp() { 97 | throw new UnsupportedOperationException(); 98 | } 99 | 100 | @Override 101 | public void setOp(boolean value) { 102 | throw new UnsupportedOperationException(); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/commands/ConfigCommand.java: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Multiverse 2 Copyright (c) the Multiverse Team 2011. * 3 | * Multiverse 2 is licensed under the BSD License. * 4 | * For more information please check the README.md file included * 5 | * with this project. * 6 | ******************************************************************************/ 7 | 8 | package com.onarandombox.MultiverseCore.commands; 9 | 10 | import com.onarandombox.MultiverseCore.MultiverseCore; 11 | import org.bukkit.ChatColor; 12 | import org.bukkit.command.CommandSender; 13 | import org.bukkit.permissions.PermissionDefault; 14 | 15 | import java.util.List; 16 | import java.util.Map; 17 | 18 | /** 19 | * Allows you to set Global MV Variables. 20 | */ 21 | public class ConfigCommand extends MultiverseCommand { 22 | public ConfigCommand(MultiverseCore plugin) { 23 | super(plugin); 24 | this.setName("Configuration"); 25 | this.setCommandUsage("/mv config " + ChatColor.GREEN + "{PROPERTY} {VALUE}"); 26 | this.setArgRange(1, 2); 27 | this.addKey("mv config"); 28 | this.addKey("mvconfig"); 29 | this.addKey("mv conf"); 30 | this.addKey("mvconf"); 31 | this.addCommandExample("/mv config show"); 32 | this.addCommandExample("/mv config " + ChatColor.GREEN + "debug" + ChatColor.AQUA + " 3"); 33 | this.addCommandExample("/mv config " + ChatColor.GREEN + "enforceaccess" + ChatColor.AQUA + " false"); 34 | this.setPermission("multiverse.core.config", "Allows you to set Global MV Variables.", PermissionDefault.OP); 35 | } 36 | 37 | @Override 38 | public void runCommand(CommandSender sender, List args) { 39 | if (args.size() <= 1) { 40 | StringBuilder builder = new StringBuilder(); 41 | Map serializedConfig = this.plugin.getMVConfig().serialize(); 42 | for (Map.Entry entry : serializedConfig.entrySet()) { 43 | builder.append(ChatColor.GREEN); 44 | builder.append(entry.getKey()); 45 | builder.append(ChatColor.WHITE).append(" = ").append(ChatColor.GOLD); 46 | builder.append(entry.getValue().toString()); 47 | builder.append(ChatColor.WHITE).append(", "); 48 | } 49 | String message = builder.toString(); 50 | message = message.substring(0, message.length() - 2); 51 | sender.sendMessage(message); 52 | return; 53 | } 54 | if (!this.plugin.getMVConfig().setConfigProperty(args.get(0).toLowerCase(), args.get(1))) { 55 | sender.sendMessage(String.format("%sSetting '%s' to '%s' failed!", ChatColor.RED, args.get(0).toLowerCase(), args.get(1))); 56 | return; 57 | } 58 | 59 | // special rule 60 | if (args.get(0).equalsIgnoreCase("firstspawnworld")) { 61 | // Don't forget to set the world! 62 | this.plugin.getMVWorldManager().setFirstSpawnWorld(args.get(1)); 63 | } 64 | 65 | if (this.plugin.saveMVConfigs()) { 66 | sender.sendMessage(ChatColor.GREEN + "SUCCESS!" + ChatColor.WHITE + " Values were updated successfully!"); 67 | this.plugin.loadConfigs(); 68 | } else { 69 | sender.sendMessage(ChatColor.RED + "FAIL!" + ChatColor.WHITE + " Check your console for details!"); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/onarandombox/MultiverseCore/utils/metrics/MetricsConfigurator.java: -------------------------------------------------------------------------------- 1 | package com.onarandombox.MultiverseCore.utils.metrics; 2 | 3 | import java.util.Collection; 4 | import java.util.Map; 5 | import java.util.function.Consumer; 6 | 7 | import com.dumptruckman.minecraft.util.Logging; 8 | import com.onarandombox.MultiverseCore.MultiverseCore; 9 | import com.onarandombox.MultiverseCore.api.MVWorldManager; 10 | import com.onarandombox.MultiverseCore.api.MultiverseWorld; 11 | import org.apache.commons.lang.WordUtils; 12 | import org.bstats.bukkit.Metrics; 13 | import org.bukkit.World; 14 | 15 | public class MetricsConfigurator { 16 | 17 | private static final int PLUGIN_ID = 7765; 18 | private static final String NO_GENERATOR_NAME = "N/A"; 19 | 20 | public static void configureMetrics(MultiverseCore plugin) { 21 | MetricsConfigurator configurator = new MetricsConfigurator(plugin); 22 | configurator.initMetrics(); 23 | } 24 | 25 | private final MultiverseCore plugin; 26 | private final Metrics metrics; 27 | 28 | private MetricsConfigurator(MultiverseCore plugin) { 29 | this.plugin = plugin; 30 | this.metrics = new Metrics(plugin, PLUGIN_ID); 31 | } 32 | 33 | private MVWorldManager getWorldManager() { 34 | return plugin.getMVWorldManager(); 35 | } 36 | 37 | private Collection getMVWorlds() { 38 | return getWorldManager().getMVWorlds(); 39 | } 40 | 41 | private void initMetrics() { 42 | try { 43 | addCustomGeneratorsMetric(); 44 | addEnvironmentsMetric(); 45 | addWorldCountMetric(); 46 | 47 | Logging.fine("Metrics enabled."); 48 | } catch (Exception e) { 49 | Logging.warning("There was an issue while enabling metrics:"); 50 | e.printStackTrace(); 51 | } 52 | } 53 | 54 | private void addCustomGeneratorsMetric() { 55 | addAdvancedPieMetric("custom_generators", map -> { 56 | for (MultiverseWorld w : getMVWorlds()) { 57 | MetricsHelper.incrementCount(map, getGeneratorName(w)); 58 | } 59 | }); 60 | } 61 | 62 | private String getGeneratorName(MultiverseWorld world) { 63 | String gen = world.getGenerator(); 64 | return (gen != null && !gen.equalsIgnoreCase("null")) ? gen.split(":")[0] : NO_GENERATOR_NAME; 65 | } 66 | 67 | private void addEnvironmentsMetric() { 68 | addAdvancedPieMetric("environments", map -> { 69 | for (MultiverseWorld w : getMVWorlds()) { 70 | MetricsHelper.incrementCount(map, titleCaseEnv(w.getEnvironment())); 71 | } 72 | }); 73 | } 74 | 75 | private String titleCaseEnv(World.Environment env) { 76 | String envName = env.name().replaceAll("_+", " "); 77 | return WordUtils.capitalizeFully(envName); 78 | } 79 | 80 | private void addWorldCountMetric() { 81 | addMultiLineMetric("world_count", map -> { 82 | int loadedWorldsCount = getMVWorlds().size(); 83 | map.put("Loaded worlds", loadedWorldsCount); 84 | map.put("Total number of worlds", loadedWorldsCount + getWorldManager().getUnloadedWorlds().size()); 85 | }); 86 | } 87 | 88 | private void addAdvancedPieMetric(String chartId, Consumer> metricsFunc) { 89 | metrics.addCustomChart(MetricsHelper.createAdvancedPieChart(chartId, metricsFunc)); 90 | } 91 | 92 | private void addMultiLineMetric(String chartId, Consumer> metricsFunc) { 93 | metrics.addCustomChart(MetricsHelper.createMultiLineChart(chartId, metricsFunc)); 94 | } 95 | } 96 | --------------------------------------------------------------------------------