Skip to content

Commit 2db55fa

Browse files
committed
Add event priority configuration for PlayerChangedWorldEvent
1 parent f446c94 commit 2db55fa

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

src/main/java/org/mvplugins/multiverse/core/config/CoreConfig.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,16 @@ public EventPriority getEventPriorityPlayerTeleport() {
641641
return configHandle.get(configNodes.eventPriorityPlayerTeleport);
642642
}
643643

644+
@ApiStatus.AvailableSince("5.5")
645+
public Try<Void> setEventPriorityPlayerWorldChange(EventPriority eventPriorityPlayerWorldChange) {
646+
return configHandle.set(configNodes.eventPriorityPlayerWorldChange, eventPriorityPlayerWorldChange);
647+
}
648+
649+
@ApiStatus.AvailableSince("5.5")
650+
public EventPriority getEventPriorityPlayerWorldChange() {
651+
return configHandle.get(configNodes.eventPriorityPlayerWorldChange);
652+
}
653+
644654
public Try<Void> setBukkitYmlPath(String bukkitYmlPath) {
645655
return configHandle.set(configNodes.bukkitYmlPath, bukkitYmlPath);
646656
}

src/main/java/org/mvplugins/multiverse/core/config/CoreConfigNodes.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,18 @@ private <N extends Node> N node(N node) {
545545
"full effect after a server restart."))
546546
.build());
547547

548+
final ConfigNode<EventPriority> eventPriorityPlayerWorldChange = node(ConfigNode.builder("event-priority.player-changed-world", EventPriority.class)
549+
.defaultValue(EventPriority.NORMAL)
550+
.name("event-priority-player-changed-world")
551+
.comment("")
552+
.comment("This config option defines the priority for the PlayerChangedWorldEvent.")
553+
.onLoadAndChange((oldValue, newValue) ->
554+
eventPriorityMapper.get().setPriority("mvcore-player-changed-world", newValue))
555+
.onChange((sender, oldValue, newValue) ->
556+
sender.sendMessage(ChatColor.YELLOW + "'event-priority.player-changed-world' config option will only take " +
557+
"full effect after a server restart."))
558+
.build());
559+
548560
private final ConfigHeaderNode miscHeader = node(ConfigHeaderNode.builder("misc")
549561
.comment("")
550562
.comment("")

src/main/java/org/mvplugins/multiverse/core/listeners/MVPlayerListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ private void teleportToDestinationOnJoin(Player player, DestinationInstance<?, ?
257257
* @param event The Event that was fired.
258258
*/
259259
@EventMethod
260-
@DefaultEventPriority(EventPriority.MONITOR)
260+
@EventPriorityKey("mvcore-player-changed-world")
261+
@DefaultEventPriority(EventPriority.NORMAL)
261262
void playerChangedWorld(PlayerChangedWorldEvent event) {
262-
// Permissions now determine whether or not to handle a gamemode.
263263
this.handleGameModeAndFlight(event.getPlayer(), event.getPlayer().getWorld());
264264
}
265265

src/test/resources/configs/fresh_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ event-priority:
5454
player-respawn: low
5555
player-spawn-location: normal
5656
player-teleport: highest
57+
player-changed-world: normal
5758

5859
misc:
5960
bukkit-yml-path: bukkit.yml

0 commit comments

Comments
 (0)