Skip to content

Commit 470e657

Browse files
authored
Merge pull request #3133 from Multiverse/ben/mv5/events
Ben/mv5/events
2 parents 668856d + d077461 commit 470e657

File tree

12 files changed

+84
-166
lines changed

12 files changed

+84
-166
lines changed

src/main/java/org/mvplugins/multiverse/core/commands/DumpsCommand.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525

2626
import org.mvplugins.multiverse.core.MultiverseCore;
2727
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
28-
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
2928
import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag;
3029
import org.mvplugins.multiverse.core.commandtools.flags.CommandValueFlag;
3130
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
32-
import org.mvplugins.multiverse.core.event.MVVersionEvent;
31+
import org.mvplugins.multiverse.core.event.MVDumpsDebugInfoEvent;
3332
import org.mvplugins.multiverse.core.utils.MVCorei18n;
3433
import org.mvplugins.multiverse.core.utils.webpaste.PasteFailedException;
3534
import org.mvplugins.multiverse.core.utils.webpaste.PasteService;
@@ -100,13 +99,13 @@ void onDumpsCommand(
10099
final ServiceTypeOption servicesType = parsedFlags.flagValue(UPLOAD_FLAG, ServiceTypeOption.PASTEGG);
101100

102101
// Initialise and add info to the debug event
103-
MVVersionEvent versionEvent = new MVVersionEvent();
102+
MVDumpsDebugInfoEvent versionEvent = new MVDumpsDebugInfoEvent();
104103
this.addDebugInfoToEvent(versionEvent);
105104
plugin.getServer().getPluginManager().callEvent(versionEvent);
106105

107106
// Add plugin list if user isn't paranoid
108107
if (!paranoid) {
109-
versionEvent.putDetailedVersionInfo("plugins.md", "# Plugins\n\n" + getPluginList());
108+
versionEvent.putDetailedDebugInfo("plugins.md", "# Plugins\n\n" + getPluginList());
110109
}
111110

112111
BukkitRunnable logPoster = new BukkitRunnable() {
@@ -122,12 +121,12 @@ public void run() {
122121
case MCLOGS -> issuer.sendInfo(MVCorei18n.DUMPS_URL_LIST,
123122
"{service}", "Logs",
124123
"{link}", postToService(PasteServiceType.MCLOGS, true, getLogs(), null));
125-
case APPEND -> versionEvent.putDetailedVersionInfo("latest.log", getLogs());
124+
case APPEND -> versionEvent.putDetailedDebugInfo("latest.log", getLogs());
126125
}
127126
}
128127

129128
// Get the files from the event
130-
final Map<String, String> files = versionEvent.getDetailedVersionInfo();
129+
final Map<String, String> files = versionEvent.getDetailedDebugInfo();
131130

132131
// Deal with uploading debug info
133132
switch (servicesType) {
@@ -180,36 +179,36 @@ private String getLogs() {
180179
return "Could not read log";
181180
}
182181

183-
private String getVersionString() {
182+
private String getDebugInfoString() {
184183
return "# Multiverse-Core Version info" + "\n\n"
185184
+ " - Multiverse-Core Version: " + this.plugin.getDescription().getVersion() + '\n'
186185
+ " - Bukkit Version: " + this.plugin.getServer().getVersion() + '\n'
187186
+ " - Loaded Worlds: " + worldManager.getLoadedWorlds() + '\n'
188187
+ " - Multiverse Plugins Loaded: " + this.plugin.getPluginCount() + '\n';
189188
}
190189

191-
private void addDebugInfoToEvent(MVVersionEvent event) {
190+
private void addDebugInfoToEvent(MVDumpsDebugInfoEvent event) {
192191
// Add the legacy file, but as markdown, so it's readable
193-
event.putDetailedVersionInfo("version.md", this.getVersionString());
192+
event.putDetailedDebugInfo("version.md", this.getDebugInfoString());
194193

195194
// add config.yml
196195
File configFile = new File(plugin.getDataFolder(), "config.yml");
197-
event.putDetailedVersionInfo("multiverse-core/config.yml", configFile);
196+
event.putDetailedDebugInfo("multiverse-core/config.yml", configFile);
198197

199198
// add worlds.yml
200199
File worldsFile = new File(plugin.getDataFolder(), "worlds.yml");
201-
event.putDetailedVersionInfo("multiverse-core/worlds.yml", worldsFile);
200+
event.putDetailedDebugInfo("multiverse-core/worlds.yml", worldsFile);
202201

203202
// Add bukkit.yml if we found it
204203
if (getBukkitConfig() != null) {
205-
event.putDetailedVersionInfo(getBukkitConfig().getPath(), getBukkitConfig());
204+
event.putDetailedDebugInfo(getBukkitConfig().getPath(), getBukkitConfig());
206205
} else {
207206
Logging.warning("/mv version could not find bukkit.yml. Not including file");
208207
}
209208

210209
// Add server.properties if we found it
211210
if (getServerProperties() != null) {
212-
event.putDetailedVersionInfo(getServerProperties().getPath(), getServerProperties());
211+
event.putDetailedDebugInfo(getServerProperties().getPath(), getServerProperties());
213212
} else {
214213
Logging.warning("/mv version could not find server.properties. Not including file");
215214
}

src/main/java/org/mvplugins/multiverse/core/event/MVConfigReloadEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Called when the Multiverse-config should be reloaded.
1717
*/
1818
public class MVConfigReloadEvent extends Event {
19-
private List<String> configsLoaded;
19+
private final List<String> configsLoaded;
2020

2121
public MVConfigReloadEvent(List<String> configsLoaded) {
2222
this.configsLoaded = configsLoaded;

src/main/java/org/mvplugins/multiverse/core/event/MVVersionEvent.java renamed to src/main/java/org/mvplugins/multiverse/core/event/MVDumpsDebugInfoEvent.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
/**
1717
* Called when somebody requests version information about Multiverse.
1818
*/
19-
public class MVVersionEvent extends Event {
19+
public class MVDumpsDebugInfoEvent extends Event {
2020

21-
private final StringBuilder versionInfoBuilder;
22-
private final Map<String, String> detailedVersionInfo;
21+
private final StringBuilder debugInfoBuilder;
22+
private final Map<String, String> detailedDebugInfo;
2323

24-
public MVVersionEvent() {
25-
versionInfoBuilder = new StringBuilder();
26-
detailedVersionInfo = new HashMap<>();
24+
public MVDumpsDebugInfoEvent() {
25+
debugInfoBuilder = new StringBuilder();
26+
detailedDebugInfo = new HashMap<>();
2727
}
2828

2929
private static final HandlerList HANDLERS = new HandlerList();
@@ -48,8 +48,8 @@ public static HandlerList getHandlerList() {
4848
* Gets the version-info currently saved in this event.
4949
* @return The version-info.
5050
*/
51-
public String getVersionInfo() {
52-
return this.versionInfoBuilder.toString();
51+
public String getDebugInfo() {
52+
return this.debugInfoBuilder.toString();
5353
}
5454

5555
/**
@@ -63,16 +63,16 @@ public String getVersionInfo() {
6363
*
6464
* @return The immutable key value mapping of files and the contents of those files.
6565
*/
66-
public Map<String, String> getDetailedVersionInfo() {
67-
return Collections.unmodifiableMap(this.detailedVersionInfo);
66+
public Map<String, String> getDetailedDebugInfo() {
67+
return Collections.unmodifiableMap(this.detailedDebugInfo);
6868
}
6969

7070
/**
7171
* Appends more version-info to the version-info currently saved in this event.
7272
* @param moreVersionInfo The version-info to add. Should end with '\n'.
7373
*/
74-
public void appendVersionInfo(String moreVersionInfo) {
75-
this.versionInfoBuilder.append(moreVersionInfo);
74+
public void appendDebugInfo(String moreVersionInfo) {
75+
this.debugInfoBuilder.append(moreVersionInfo);
7676
}
7777

7878
private String readFile(final String filename) {
@@ -104,16 +104,16 @@ private String readFile(final String filename) {
104104
* @param fileName The name of the file.
105105
* @param contents The contents of the file.
106106
*/
107-
public void putDetailedVersionInfo(String fileName, String contents) {
108-
this.detailedVersionInfo.put(fileName, contents);
107+
public void putDetailedDebugInfo(String fileName, String contents) {
108+
this.detailedDebugInfo.put(fileName, contents);
109109
}
110110

111111
/**
112112
* Adds a file to to the detailed version-info currently saved in this event.
113113
* @param filename The name of the file.
114114
* @param file The file.
115115
*/
116-
public void putDetailedVersionInfo(String filename, File file) {
117-
this.putDetailedVersionInfo(filename, readFile(file.getAbsolutePath()));
116+
public void putDetailedDebugInfo(String filename, File file) {
117+
this.putDetailedDebugInfo(filename, readFile(file.getAbsolutePath()));
118118
}
119119
}

src/main/java/org/mvplugins/multiverse/core/event/MVPlayerTouchedPortalEvent.java

Lines changed: 0 additions & 93 deletions
This file was deleted.

src/main/java/org/mvplugins/multiverse/core/event/MVRespawnEvent.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
/**
1616
* Called when a player is respawning.
1717
*/
18+
// todo: remove or update its usage. The respawnMethod is always "compatibility" for some reason
19+
@Deprecated
1820
public class MVRespawnEvent extends Event {
19-
private Player player;
21+
private final Player player;
22+
private final String respawnMethod;
2023
private Location location;
21-
private String respawnMethod;
22-
2324

2425
public MVRespawnEvent(Location spawningAt, Player p, String respawnMethod) {
2526
this.player = p;

src/main/java/org/mvplugins/multiverse/core/event/MVTeleportEvent.java renamed to src/main/java/org/mvplugins/multiverse/core/event/MVTeleportDestinationEvent.java

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import org.bukkit.Location;
1111
import org.bukkit.command.CommandSender;
12+
import org.bukkit.entity.Entity;
1213
import org.bukkit.entity.Player;
1314
import org.bukkit.event.Cancellable;
1415
import org.bukkit.event.Event;
@@ -18,20 +19,18 @@
1819
import org.mvplugins.multiverse.core.teleportation.AsyncSafetyTeleporter;
1920

2021
/**
21-
* Event that gets called when a player use the /mvtp command.
22+
* Event that gets called when a player teleports to a {@link DestinationInstance} with {@link AsyncSafetyTeleporter}.
2223
*/
23-
public class MVTeleportEvent extends Event implements Cancellable {
24-
private Player teleportee;
25-
private CommandSender teleporter;
26-
private DestinationInstance<?, ?> dest;
27-
private boolean useSafeTeleport;
24+
public class MVTeleportDestinationEvent extends Event implements Cancellable {
25+
private final Entity teleportee;
26+
private final CommandSender teleporter;
27+
private final DestinationInstance<?, ?> dest;
2828
private boolean isCancelled;
2929

30-
public MVTeleportEvent(DestinationInstance<?, ?> dest, Player teleportee, CommandSender teleporter, boolean safeTeleport) {
30+
public MVTeleportDestinationEvent(DestinationInstance<?, ?> dest, Entity teleportee, CommandSender teleporter) {
3131
this.teleportee = teleportee;
3232
this.teleporter = teleporter;
3333
this.dest = dest;
34-
this.useSafeTeleport = safeTeleport;
3534
}
3635

3736
private static final HandlerList HANDLERS = new HandlerList();
@@ -57,7 +56,7 @@ public static HandlerList getHandlerList() {
5756
*
5857
* @return The player who will be teleported by this event.
5958
*/
60-
public Player getTeleportee() {
59+
public Entity getTeleportee() {
6160
return this.teleportee;
6261
}
6362

@@ -88,14 +87,6 @@ public CommandSender getTeleporter() {
8887
return this.dest;
8988
}
9089

91-
/**
92-
* Looks if this {@link MVTeleportEvent} is using the {@link AsyncSafetyTeleporter}.
93-
* @return True if this {@link MVTeleportEvent} is using the {@link AsyncSafetyTeleporter}.
94-
*/
95-
public boolean isUsingSafeTTeleporter() {
96-
return useSafeTeleport;
97-
}
98-
9990
@Override
10091
public boolean isCancelled() {
10192
return this.isCancelled;

src/main/java/org/mvplugins/multiverse/core/event/MVWorldDeleteEvent.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import org.bukkit.event.Event;
55
import org.bukkit.event.HandlerList;
66

7+
import org.jetbrains.annotations.NotNull;
78
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
8-
import org.mvplugins.multiverse.core.world.MultiverseWorld;
99

1010
/**
1111
* Called when a world is about to be deleted by Multiverse.
@@ -14,14 +14,9 @@ public class MVWorldDeleteEvent extends Event implements Cancellable {
1414
private boolean cancelled = false;
1515

1616
private final LoadedMultiverseWorld world;
17-
private final boolean removeFromConfig;
1817

19-
public MVWorldDeleteEvent(LoadedMultiverseWorld world, boolean removeFromConfig) {
20-
if (world == null) {
21-
throw new IllegalArgumentException("world can't be null!");
22-
}
18+
public MVWorldDeleteEvent(@NotNull LoadedMultiverseWorld world) {
2319
this.world = world;
24-
this.removeFromConfig = removeFromConfig;
2520
}
2621

2722
private static final HandlerList HANDLERS = new HandlerList();
@@ -61,19 +56,9 @@ public void setCancelled(boolean cancel) {
6156
/**
6257
* Gets the world that's about to be deleted.
6358
*
64-
* @return That {@link MultiverseWorld}.
59+
* @return That {@link LoadedMultiverseWorld}.
6560
*/
6661
public LoadedMultiverseWorld getWorld() {
6762
return world;
6863
}
69-
70-
/**
71-
* Is the world about to be removed from the config?
72-
*
73-
* @return True if yes, false if no.
74-
*/
75-
public boolean removeWorldFromConfig() {
76-
return removeFromConfig;
77-
}
78-
7964
}

src/main/java/org/mvplugins/multiverse/core/event/MVWorldPropertyChangeEvent.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
* To get the new value, use {@link #getTheNewValue()}. To change it, use {@link #setTheNewValue(Object)}.
2626
* @param <T> The type of the property that was set.
2727
*/
28+
// todo: Implement or remove this
29+
@Deprecated
2830
public class MVWorldPropertyChangeEvent<T> extends Event implements Cancellable {
2931
private MultiverseWorld world;
3032
private CommandSender changer;

0 commit comments

Comments
 (0)