From b1afd8f7860cbbe19f8386e00e6c068249ec8ec4 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Sat, 23 Nov 2024 21:24:14 +0800 Subject: [PATCH 1/7] Implement MVTeleportDestinationEvent event --- ...t.java => MVTeleportDestinationEvent.java} | 25 ++++++------------- .../teleportation/AsyncSafetyTeleporter.java | 19 ++++++++++++-- .../core/teleportation/TeleportResult.java | 1 + 3 files changed, 26 insertions(+), 19 deletions(-) rename src/main/java/org/mvplugins/multiverse/core/event/{MVTeleportEvent.java => MVTeleportDestinationEvent.java} (76%) diff --git a/src/main/java/org/mvplugins/multiverse/core/event/MVTeleportEvent.java b/src/main/java/org/mvplugins/multiverse/core/event/MVTeleportDestinationEvent.java similarity index 76% rename from src/main/java/org/mvplugins/multiverse/core/event/MVTeleportEvent.java rename to src/main/java/org/mvplugins/multiverse/core/event/MVTeleportDestinationEvent.java index 196ddb590..46a6c2727 100644 --- a/src/main/java/org/mvplugins/multiverse/core/event/MVTeleportEvent.java +++ b/src/main/java/org/mvplugins/multiverse/core/event/MVTeleportDestinationEvent.java @@ -9,6 +9,7 @@ import org.bukkit.Location; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; @@ -18,20 +19,18 @@ import org.mvplugins.multiverse.core.teleportation.AsyncSafetyTeleporter; /** - * Event that gets called when a player use the /mvtp command. + * Event that gets called when a player teleports to a {@link DestinationInstance} with {@link AsyncSafetyTeleporter}. */ -public class MVTeleportEvent extends Event implements Cancellable { - private Player teleportee; - private CommandSender teleporter; - private DestinationInstance dest; - private boolean useSafeTeleport; +public class MVTeleportDestinationEvent extends Event implements Cancellable { + private final Entity teleportee; + private final CommandSender teleporter; + private final DestinationInstance dest; private boolean isCancelled; - public MVTeleportEvent(DestinationInstance dest, Player teleportee, CommandSender teleporter, boolean safeTeleport) { + public MVTeleportDestinationEvent(DestinationInstance dest, Entity teleportee, CommandSender teleporter) { this.teleportee = teleportee; this.teleporter = teleporter; this.dest = dest; - this.useSafeTeleport = safeTeleport; } private static final HandlerList HANDLERS = new HandlerList(); @@ -57,7 +56,7 @@ public static HandlerList getHandlerList() { * * @return The player who will be teleported by this event. */ - public Player getTeleportee() { + public Entity getTeleportee() { return this.teleportee; } @@ -88,14 +87,6 @@ public CommandSender getTeleporter() { return this.dest; } - /** - * Looks if this {@link MVTeleportEvent} is using the {@link AsyncSafetyTeleporter}. - * @return True if this {@link MVTeleportEvent} is using the {@link AsyncSafetyTeleporter}. - */ - public boolean isUsingSafeTTeleporter() { - return useSafeTeleport; - } - @Override public boolean isCancelled() { return this.isCancelled; diff --git a/src/main/java/org/mvplugins/multiverse/core/teleportation/AsyncSafetyTeleporter.java b/src/main/java/org/mvplugins/multiverse/core/teleportation/AsyncSafetyTeleporter.java index 9c9de783a..4cfcb7f87 100644 --- a/src/main/java/org/mvplugins/multiverse/core/teleportation/AsyncSafetyTeleporter.java +++ b/src/main/java/org/mvplugins/multiverse/core/teleportation/AsyncSafetyTeleporter.java @@ -9,12 +9,14 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.plugin.PluginManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jvnet.hk2.annotations.Service; import org.mvplugins.multiverse.core.api.BlockSafety; import org.mvplugins.multiverse.core.destination.DestinationInstance; +import org.mvplugins.multiverse.core.event.MVTeleportDestinationEvent; import org.mvplugins.multiverse.core.utils.result.Async; import org.mvplugins.multiverse.core.utils.result.AsyncAttempt; import org.mvplugins.multiverse.core.utils.result.Attempt; @@ -26,13 +28,16 @@ public class AsyncSafetyTeleporter { private final BlockSafety blockSafety; private final TeleportQueue teleportQueue; + private final PluginManager pluginManager; @Inject AsyncSafetyTeleporter( - BlockSafety blockSafety, - TeleportQueue teleportQueue) { + @NotNull BlockSafety blockSafety, + @NotNull TeleportQueue teleportQueue, + @NotNull PluginManager pluginManager) { this.blockSafety = blockSafety; this.teleportQueue = teleportQueue; + this.pluginManager = pluginManager; } public AsyncAttempt teleportSafely( @@ -57,6 +62,11 @@ public AsyncAttempt teleportSafely( if (destination == null) { return AsyncAttempt.failure(TeleportResult.Failure.NULL_DESTINATION); } + MVTeleportDestinationEvent event = new MVTeleportDestinationEvent(destination, teleportee, teleporter); + this.pluginManager.callEvent(event); + if (event.isCancelled()) { + return AsyncAttempt.failure(TeleportResult.Failure.EVENT_CANCELLED); + } return destination.getLocation(teleportee) .map(location -> destination.checkTeleportSafety() ? teleportSafely(teleporter, teleportee, location) @@ -105,6 +115,11 @@ public AsyncAttempt teleport( if (destination == null) { return AsyncAttempt.failure(TeleportResult.Failure.NULL_DESTINATION); } + MVTeleportDestinationEvent event = new MVTeleportDestinationEvent(destination, teleportee, teleporter); + this.pluginManager.callEvent(event); + if (event.isCancelled()) { + return AsyncAttempt.failure(TeleportResult.Failure.EVENT_CANCELLED); + } return destination.getLocation(teleportee) .map(location -> teleport(teleporter, teleportee, location)) .getOrElse(AsyncAttempt.failure(TeleportResult.Failure.NULL_LOCATION)); diff --git a/src/main/java/org/mvplugins/multiverse/core/teleportation/TeleportResult.java b/src/main/java/org/mvplugins/multiverse/core/teleportation/TeleportResult.java index 93b37ff95..ef4835996 100644 --- a/src/main/java/org/mvplugins/multiverse/core/teleportation/TeleportResult.java +++ b/src/main/java/org/mvplugins/multiverse/core/teleportation/TeleportResult.java @@ -15,5 +15,6 @@ public enum Failure implements FailureReason { TELEPORT_FAILED, TELEPORT_FAILED_EXCEPTION, PLAYER_OFFLINE, + EVENT_CANCELLED, } } From 9781e8350cd7151fb9b02c2d142d444aa5c04107 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Sat, 23 Nov 2024 21:24:30 +0800 Subject: [PATCH 2/7] Remove unused MVPlayerTouchedPortalEvent --- .../event/MVPlayerTouchedPortalEvent.java | 93 ------------------- 1 file changed, 93 deletions(-) delete mode 100644 src/main/java/org/mvplugins/multiverse/core/event/MVPlayerTouchedPortalEvent.java diff --git a/src/main/java/org/mvplugins/multiverse/core/event/MVPlayerTouchedPortalEvent.java b/src/main/java/org/mvplugins/multiverse/core/event/MVPlayerTouchedPortalEvent.java deleted file mode 100644 index 8f04f77b4..000000000 --- a/src/main/java/org/mvplugins/multiverse/core/event/MVPlayerTouchedPortalEvent.java +++ /dev/null @@ -1,93 +0,0 @@ -/****************************************************************************** - * Multiverse 2 Copyright (c) the Multiverse Team 2011. * - * Multiverse 2 is licensed under the BSD License. * - * For more information please check the README.md file included * - * with this project. * - ******************************************************************************/ - -package org.mvplugins.multiverse.core.event; - -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -/** - * This event is thrown when a portal is touched. - */ -public class MVPlayerTouchedPortalEvent extends Event implements Cancellable { - private Player p; - private Location l; - private boolean isCancelled; - private boolean canUse = true; - - public MVPlayerTouchedPortalEvent(Player p, Location l) { - this.p = p; - this.l = l; - } - - private static final HandlerList HANDLERS = new HandlerList(); - - /** - * {@inheritDoc} - */ - @Override - public HandlerList getHandlers() { - return HANDLERS; - } - - /** - * Gets the handler list. This is required by the event system. - * @return A list of HANDLERS. - */ - public static HandlerList getHandlerList() { - return HANDLERS; - } - - /** - * Gets the {@link Location} of the portal-block that was touched. - * @return The {@link Location} of the portal-block that was touched. - */ - public Location getBlockTouched() { - return this.l; - } - - /** - * Gets the {@link Player} that's touching the portal. - * @return The {@link Player} that's touching the portal. - */ - public Player getPlayer() { - return this.p; - } - - /** - * Gets whether or not the player in this event can use this portal. - * - * @return True if the player can use this portal. - */ - public boolean canUseThisPortal() { - return this.canUse; - } - - /** - * Sets whether or not the player in this event can use this portal. - *

- * Setting this to false will cause the player to bounce back! - * - * @param canUse Whether or not the user can go through this portal. - */ - public void setCanUseThisPortal(boolean canUse) { - this.canUse = canUse; - } - - @Override - public boolean isCancelled() { - return this.isCancelled; - } - - @Override - public void setCancelled(boolean b) { - this.isCancelled = b; - } -} From c0ceb4f993ee323bb88797fc60ede48547130d6d Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Sat, 23 Nov 2024 21:25:23 +0800 Subject: [PATCH 3/7] Rename MVVersionEvent to MVDumpsDebugInfoEvent for clarity --- .../mvplugins/multiverse/core/commands/DumpsCommand.java | 7 +++---- .../{MVVersionEvent.java => MVDumpsDebugInfoEvent.java} | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) rename src/main/java/org/mvplugins/multiverse/core/event/{MVVersionEvent.java => MVDumpsDebugInfoEvent.java} (97%) diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java index f01e543f7..66321135e 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java @@ -25,11 +25,10 @@ import org.mvplugins.multiverse.core.MultiverseCore; import org.mvplugins.multiverse.core.commandtools.MVCommandManager; -import org.mvplugins.multiverse.core.commandtools.MultiverseCommand; import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag; import org.mvplugins.multiverse.core.commandtools.flags.CommandValueFlag; import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags; -import org.mvplugins.multiverse.core.event.MVVersionEvent; +import org.mvplugins.multiverse.core.event.MVDumpsDebugInfoEvent; import org.mvplugins.multiverse.core.utils.MVCorei18n; import org.mvplugins.multiverse.core.utils.webpaste.PasteFailedException; import org.mvplugins.multiverse.core.utils.webpaste.PasteService; @@ -100,7 +99,7 @@ void onDumpsCommand( final ServiceTypeOption servicesType = parsedFlags.flagValue(UPLOAD_FLAG, ServiceTypeOption.PASTEGG); // Initialise and add info to the debug event - MVVersionEvent versionEvent = new MVVersionEvent(); + MVDumpsDebugInfoEvent versionEvent = new MVDumpsDebugInfoEvent(); this.addDebugInfoToEvent(versionEvent); plugin.getServer().getPluginManager().callEvent(versionEvent); @@ -188,7 +187,7 @@ private String getVersionString() { + " - Multiverse Plugins Loaded: " + this.plugin.getPluginCount() + '\n'; } - private void addDebugInfoToEvent(MVVersionEvent event) { + private void addDebugInfoToEvent(MVDumpsDebugInfoEvent event) { // Add the legacy file, but as markdown, so it's readable event.putDetailedVersionInfo("version.md", this.getVersionString()); diff --git a/src/main/java/org/mvplugins/multiverse/core/event/MVVersionEvent.java b/src/main/java/org/mvplugins/multiverse/core/event/MVDumpsDebugInfoEvent.java similarity index 97% rename from src/main/java/org/mvplugins/multiverse/core/event/MVVersionEvent.java rename to src/main/java/org/mvplugins/multiverse/core/event/MVDumpsDebugInfoEvent.java index d6b79900f..e7608d317 100644 --- a/src/main/java/org/mvplugins/multiverse/core/event/MVVersionEvent.java +++ b/src/main/java/org/mvplugins/multiverse/core/event/MVDumpsDebugInfoEvent.java @@ -16,12 +16,12 @@ /** * Called when somebody requests version information about Multiverse. */ -public class MVVersionEvent extends Event { +public class MVDumpsDebugInfoEvent extends Event { private final StringBuilder versionInfoBuilder; private final Map detailedVersionInfo; - public MVVersionEvent() { + public MVDumpsDebugInfoEvent() { versionInfoBuilder = new StringBuilder(); detailedVersionInfo = new HashMap<>(); } From 07ed9fbc48ff2d13c70ee9a8e701fafefe754a40 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Sat, 23 Nov 2024 21:28:05 +0800 Subject: [PATCH 4/7] Cleanup MVConfigReloadEvent and deprecate MVRespawnEvent --- .../multiverse/core/event/MVConfigReloadEvent.java | 2 +- .../mvplugins/multiverse/core/event/MVRespawnEvent.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/mvplugins/multiverse/core/event/MVConfigReloadEvent.java b/src/main/java/org/mvplugins/multiverse/core/event/MVConfigReloadEvent.java index a80a39eeb..f6fcadf5d 100644 --- a/src/main/java/org/mvplugins/multiverse/core/event/MVConfigReloadEvent.java +++ b/src/main/java/org/mvplugins/multiverse/core/event/MVConfigReloadEvent.java @@ -16,7 +16,7 @@ * Called when the Multiverse-config should be reloaded. */ public class MVConfigReloadEvent extends Event { - private List configsLoaded; + private final List configsLoaded; public MVConfigReloadEvent(List configsLoaded) { this.configsLoaded = configsLoaded; diff --git a/src/main/java/org/mvplugins/multiverse/core/event/MVRespawnEvent.java b/src/main/java/org/mvplugins/multiverse/core/event/MVRespawnEvent.java index 5190122d3..ffc51f225 100644 --- a/src/main/java/org/mvplugins/multiverse/core/event/MVRespawnEvent.java +++ b/src/main/java/org/mvplugins/multiverse/core/event/MVRespawnEvent.java @@ -15,11 +15,12 @@ /** * Called when a player is respawning. */ +// todo: remove or update its usage. The respawnMethod is always "compatibility" for some reason +@Deprecated public class MVRespawnEvent extends Event { - private Player player; + private final Player player; + private final String respawnMethod; private Location location; - private String respawnMethod; - public MVRespawnEvent(Location spawningAt, Player p, String respawnMethod) { this.player = p; From e93e2aa5f4b75ac05fc967c7a3e9b18c7fd7fcda Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Sun, 24 Nov 2024 11:21:01 +0800 Subject: [PATCH 5/7] Implement MVWorldDeleteEvent event --- .../core/event/MVWorldDeleteEvent.java | 21 +++---------------- .../multiverse/core/world/WorldManager.java | 15 +++++++++++-- .../world/reasons/DeleteFailureReason.java | 8 ++++++- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/mvplugins/multiverse/core/event/MVWorldDeleteEvent.java b/src/main/java/org/mvplugins/multiverse/core/event/MVWorldDeleteEvent.java index 0438d84aa..56610c479 100644 --- a/src/main/java/org/mvplugins/multiverse/core/event/MVWorldDeleteEvent.java +++ b/src/main/java/org/mvplugins/multiverse/core/event/MVWorldDeleteEvent.java @@ -4,8 +4,8 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld; -import org.mvplugins.multiverse.core.world.MultiverseWorld; /** * Called when a world is about to be deleted by Multiverse. @@ -14,14 +14,9 @@ public class MVWorldDeleteEvent extends Event implements Cancellable { private boolean cancelled = false; private final LoadedMultiverseWorld world; - private final boolean removeFromConfig; - public MVWorldDeleteEvent(LoadedMultiverseWorld world, boolean removeFromConfig) { - if (world == null) { - throw new IllegalArgumentException("world can't be null!"); - } + public MVWorldDeleteEvent(@NotNull LoadedMultiverseWorld world) { this.world = world; - this.removeFromConfig = removeFromConfig; } private static final HandlerList HANDLERS = new HandlerList(); @@ -61,19 +56,9 @@ public void setCancelled(boolean cancel) { /** * Gets the world that's about to be deleted. * - * @return That {@link MultiverseWorld}. + * @return That {@link LoadedMultiverseWorld}. */ public LoadedMultiverseWorld getWorld() { return world; } - - /** - * Is the world about to be removed from the config? - * - * @return True if yes, false if no. - */ - public boolean removeWorldFromConfig() { - return removeFromConfig; - } - } diff --git a/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java b/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java index de522455c..b130d0748 100644 --- a/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/WorldManager.java @@ -20,13 +20,14 @@ import org.bukkit.World; import org.bukkit.WorldCreator; import org.bukkit.WorldType; -import org.bukkit.entity.Player; +import org.bukkit.plugin.PluginManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jvnet.hk2.annotations.Service; import org.mvplugins.multiverse.core.api.BlockSafety; import org.mvplugins.multiverse.core.api.LocationManipulation; +import org.mvplugins.multiverse.core.event.MVWorldDeleteEvent; import org.mvplugins.multiverse.core.utils.message.MessageReplacement; import org.mvplugins.multiverse.core.utils.result.Attempt; import org.mvplugins.multiverse.core.utils.result.FailureReason; @@ -75,6 +76,7 @@ public class WorldManager { private final FilesManipulator filesManipulator; private final BlockSafety blockSafety; private final LocationManipulation locationManipulation; + private final PluginManager pluginManager; @Inject WorldManager( @@ -84,7 +86,9 @@ public class WorldManager { @NotNull PlayerWorldTeleporter playerWorldActions, @NotNull FilesManipulator filesManipulator, @NotNull BlockSafety blockSafety, - @NotNull LocationManipulation locationManipulation) { + @NotNull LocationManipulation locationManipulation, + @NotNull PluginManager pluginManager) { + this.pluginManager = pluginManager; this.worldsMap = new HashMap<>(); this.loadedWorldsMap = new HashMap<>(); this.unloadTracker = new ArrayList<>(); @@ -476,6 +480,13 @@ public Attempt deleteWorld(@NotNull LoadedMultivers AtomicReference worldFolder = new AtomicReference<>(); return validateWorldToDelete(world) .peek(worldFolder::set) + .mapAttempt(() -> { + MVWorldDeleteEvent event = new MVWorldDeleteEvent(world); + pluginManager.callEvent(event); + return event.isCancelled() + ? Attempt.failure(DeleteFailureReason.EVENT_CANCELLED) + : Attempt.success(null); + }) .mapAttempt(() -> removeWorld(world).transform(DeleteFailureReason.REMOVE_FAILED)) .mapAttempt(() -> filesManipulator.deleteFolder(worldFolder.get()).fold( exception -> worldActionResult(DeleteFailureReason.FAILED_TO_DELETE_FOLDER, diff --git a/src/main/java/org/mvplugins/multiverse/core/world/reasons/DeleteFailureReason.java b/src/main/java/org/mvplugins/multiverse/core/world/reasons/DeleteFailureReason.java index 454f57de2..31ad26983 100644 --- a/src/main/java/org/mvplugins/multiverse/core/world/reasons/DeleteFailureReason.java +++ b/src/main/java/org/mvplugins/multiverse/core/world/reasons/DeleteFailureReason.java @@ -3,6 +3,7 @@ import co.aikar.locales.MessageKey; import co.aikar.locales.MessageKeyProvider; +import org.mvplugins.multiverse.core.event.MVWorldDeleteEvent; import org.mvplugins.multiverse.core.utils.MVCorei18n; import org.mvplugins.multiverse.core.utils.result.FailureReason; @@ -33,7 +34,12 @@ public enum DeleteFailureReason implements FailureReason { /** * The world folder could not be deleted. */ - FAILED_TO_DELETE_FOLDER(MVCorei18n.DELETEWORLD_FAILEDTODELETEFOLDER); + FAILED_TO_DELETE_FOLDER(MVCorei18n.DELETEWORLD_FAILEDTODELETEFOLDER), + + /** + * The {@link MVWorldDeleteEvent} was cancelled. + */ + EVENT_CANCELLED(MVCorei18n.GENERIC_FAILURE); // todo: messaging private final MessageKeyProvider message; From 8d852c5269ad6adeb6f3b7461d8423b50570f9a2 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Sun, 24 Nov 2024 11:21:13 +0800 Subject: [PATCH 6/7] Add todo for MVWorldPropertyChangeEvent --- .../multiverse/core/event/MVWorldPropertyChangeEvent.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/mvplugins/multiverse/core/event/MVWorldPropertyChangeEvent.java b/src/main/java/org/mvplugins/multiverse/core/event/MVWorldPropertyChangeEvent.java index e67dbd9b0..c6bb47188 100644 --- a/src/main/java/org/mvplugins/multiverse/core/event/MVWorldPropertyChangeEvent.java +++ b/src/main/java/org/mvplugins/multiverse/core/event/MVWorldPropertyChangeEvent.java @@ -25,6 +25,8 @@ * To get the new value, use {@link #getTheNewValue()}. To change it, use {@link #setTheNewValue(Object)}. * @param The type of the property that was set. */ +// todo: Implement or remove this +@Deprecated public class MVWorldPropertyChangeEvent extends Event implements Cancellable { private MultiverseWorld world; private CommandSender changer; From d0774614c846cb3d040c88cf0113c187862e3f85 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Sun, 24 Nov 2024 13:26:22 +0800 Subject: [PATCH 7/7] Rename MVDumpsDebugInfoEvent methods to reflect the class name change --- .../core/commands/DumpsCommand.java | 18 ++++++------ .../core/event/MVDumpsDebugInfoEvent.java | 28 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java b/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java index 66321135e..e1cd1916f 100644 --- a/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java +++ b/src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java @@ -105,7 +105,7 @@ void onDumpsCommand( // Add plugin list if user isn't paranoid if (!paranoid) { - versionEvent.putDetailedVersionInfo("plugins.md", "# Plugins\n\n" + getPluginList()); + versionEvent.putDetailedDebugInfo("plugins.md", "# Plugins\n\n" + getPluginList()); } BukkitRunnable logPoster = new BukkitRunnable() { @@ -121,12 +121,12 @@ public void run() { case MCLOGS -> issuer.sendInfo(MVCorei18n.DUMPS_URL_LIST, "{service}", "Logs", "{link}", postToService(PasteServiceType.MCLOGS, true, getLogs(), null)); - case APPEND -> versionEvent.putDetailedVersionInfo("latest.log", getLogs()); + case APPEND -> versionEvent.putDetailedDebugInfo("latest.log", getLogs()); } } // Get the files from the event - final Map files = versionEvent.getDetailedVersionInfo(); + final Map files = versionEvent.getDetailedDebugInfo(); // Deal with uploading debug info switch (servicesType) { @@ -179,7 +179,7 @@ private String getLogs() { return "Could not read log"; } - private String getVersionString() { + private String getDebugInfoString() { return "# Multiverse-Core Version info" + "\n\n" + " - Multiverse-Core Version: " + this.plugin.getDescription().getVersion() + '\n' + " - Bukkit Version: " + this.plugin.getServer().getVersion() + '\n' @@ -189,26 +189,26 @@ private String getVersionString() { private void addDebugInfoToEvent(MVDumpsDebugInfoEvent event) { // Add the legacy file, but as markdown, so it's readable - event.putDetailedVersionInfo("version.md", this.getVersionString()); + event.putDetailedDebugInfo("version.md", this.getDebugInfoString()); // add config.yml File configFile = new File(plugin.getDataFolder(), "config.yml"); - event.putDetailedVersionInfo("multiverse-core/config.yml", configFile); + event.putDetailedDebugInfo("multiverse-core/config.yml", configFile); // add worlds.yml File worldsFile = new File(plugin.getDataFolder(), "worlds.yml"); - event.putDetailedVersionInfo("multiverse-core/worlds.yml", worldsFile); + event.putDetailedDebugInfo("multiverse-core/worlds.yml", worldsFile); // Add bukkit.yml if we found it if (getBukkitConfig() != null) { - event.putDetailedVersionInfo(getBukkitConfig().getPath(), getBukkitConfig()); + event.putDetailedDebugInfo(getBukkitConfig().getPath(), getBukkitConfig()); } else { Logging.warning("/mv version could not find bukkit.yml. Not including file"); } // Add server.properties if we found it if (getServerProperties() != null) { - event.putDetailedVersionInfo(getServerProperties().getPath(), getServerProperties()); + event.putDetailedDebugInfo(getServerProperties().getPath(), getServerProperties()); } else { Logging.warning("/mv version could not find server.properties. Not including file"); } diff --git a/src/main/java/org/mvplugins/multiverse/core/event/MVDumpsDebugInfoEvent.java b/src/main/java/org/mvplugins/multiverse/core/event/MVDumpsDebugInfoEvent.java index e7608d317..876208503 100644 --- a/src/main/java/org/mvplugins/multiverse/core/event/MVDumpsDebugInfoEvent.java +++ b/src/main/java/org/mvplugins/multiverse/core/event/MVDumpsDebugInfoEvent.java @@ -18,12 +18,12 @@ */ public class MVDumpsDebugInfoEvent extends Event { - private final StringBuilder versionInfoBuilder; - private final Map detailedVersionInfo; + private final StringBuilder debugInfoBuilder; + private final Map detailedDebugInfo; public MVDumpsDebugInfoEvent() { - versionInfoBuilder = new StringBuilder(); - detailedVersionInfo = new HashMap<>(); + debugInfoBuilder = new StringBuilder(); + detailedDebugInfo = new HashMap<>(); } private static final HandlerList HANDLERS = new HandlerList(); @@ -48,8 +48,8 @@ public static HandlerList getHandlerList() { * Gets the version-info currently saved in this event. * @return The version-info. */ - public String getVersionInfo() { - return this.versionInfoBuilder.toString(); + public String getDebugInfo() { + return this.debugInfoBuilder.toString(); } /** @@ -63,16 +63,16 @@ public String getVersionInfo() { * * @return The immutable key value mapping of files and the contents of those files. */ - public Map getDetailedVersionInfo() { - return Collections.unmodifiableMap(this.detailedVersionInfo); + public Map getDetailedDebugInfo() { + return Collections.unmodifiableMap(this.detailedDebugInfo); } /** * Appends more version-info to the version-info currently saved in this event. * @param moreVersionInfo The version-info to add. Should end with '\n'. */ - public void appendVersionInfo(String moreVersionInfo) { - this.versionInfoBuilder.append(moreVersionInfo); + public void appendDebugInfo(String moreVersionInfo) { + this.debugInfoBuilder.append(moreVersionInfo); } private String readFile(final String filename) { @@ -104,8 +104,8 @@ private String readFile(final String filename) { * @param fileName The name of the file. * @param contents The contents of the file. */ - public void putDetailedVersionInfo(String fileName, String contents) { - this.detailedVersionInfo.put(fileName, contents); + public void putDetailedDebugInfo(String fileName, String contents) { + this.detailedDebugInfo.put(fileName, contents); } /** @@ -113,7 +113,7 @@ public void putDetailedVersionInfo(String fileName, String contents) { * @param filename The name of the file. * @param file The file. */ - public void putDetailedVersionInfo(String filename, File file) { - this.putDetailedVersionInfo(filename, readFile(file.getAbsolutePath())); + public void putDetailedDebugInfo(String filename, File file) { + this.putDetailedDebugInfo(filename, readFile(file.getAbsolutePath())); } }