Skip to content

Commit 815637e

Browse files
authored
Merge pull request #3412 from Multiverse/feat/world-change-priority
Add event priority configuration for PlayerChangedWorldEvent
2 parents 7819438 + 2db55fa commit 815637e

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
@@ -651,6 +651,16 @@ public EventPriority getEventPriorityPlayerTeleport() {
651651
return configHandle.get(configNodes.eventPriorityPlayerTeleport);
652652
}
653653

654+
@ApiStatus.AvailableSince("5.5")
655+
public Try<Void> setEventPriorityPlayerWorldChange(EventPriority eventPriorityPlayerWorldChange) {
656+
return configHandle.set(configNodes.eventPriorityPlayerWorldChange, eventPriorityPlayerWorldChange);
657+
}
658+
659+
@ApiStatus.AvailableSince("5.5")
660+
public EventPriority getEventPriorityPlayerWorldChange() {
661+
return configHandle.get(configNodes.eventPriorityPlayerWorldChange);
662+
}
663+
654664
public Try<Void> setBukkitYmlPath(String bukkitYmlPath) {
655665
return configHandle.set(configNodes.bukkitYmlPath, bukkitYmlPath);
656666
}

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

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

558+
final ConfigNode<EventPriority> eventPriorityPlayerWorldChange = node(ConfigNode.builder("event-priority.player-changed-world", EventPriority.class)
559+
.defaultValue(EventPriority.NORMAL)
560+
.name("event-priority-player-changed-world")
561+
.comment("")
562+
.comment("This config option defines the priority for the PlayerChangedWorldEvent.")
563+
.onLoadAndChange((oldValue, newValue) ->
564+
eventPriorityMapper.get().setPriority("mvcore-player-changed-world", newValue))
565+
.onChange((sender, oldValue, newValue) ->
566+
sender.sendMessage(ChatColor.YELLOW + "'event-priority.player-changed-world' config option will only take " +
567+
"full effect after a server restart."))
568+
.build());
569+
558570
private final ConfigHeaderNode miscHeader = node(ConfigHeaderNode.builder("misc")
559571
.comment("")
560572
.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
@@ -255,9 +255,9 @@ private void teleportToDestinationOnJoin(Player player, DestinationInstance<?, ?
255255
* @param event The Event that was fired.
256256
*/
257257
@EventMethod
258-
@DefaultEventPriority(EventPriority.MONITOR)
258+
@EventPriorityKey("mvcore-player-changed-world")
259+
@DefaultEventPriority(EventPriority.NORMAL)
259260
void playerChangedWorld(PlayerChangedWorldEvent event) {
260-
// Permissions now determine whether or not to handle a gamemode.
261261
this.handleGameModeAndFlight(event.getPlayer(), event.getPlayer().getWorld());
262262
}
263263

src/test/resources/configs/fresh_config.yml

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

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

0 commit comments

Comments
 (0)