forked from public-mirrors/HuskSync
Make event priority configurable for three key events
parent
51cf7beeb8
commit
3bfea58f35
@ -0,0 +1,37 @@
|
||||
package net.william278.husksync.listener;
|
||||
|
||||
import net.william278.husksync.config.Settings;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface BukkitDeathEventListener extends Listener {
|
||||
|
||||
boolean handleEvent(@NotNull Settings.EventType type, @NotNull Settings.EventPriority priority);
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
default void onPlayerDeathHighest(@NotNull PlayerDeathEvent event) {
|
||||
if (handleEvent(Settings.EventType.DEATH_LISTENER, Settings.EventPriority.HIGHEST)) {
|
||||
handlePlayerDeath(event);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
default void onPlayerDeath(@NotNull PlayerDeathEvent event) {
|
||||
if (handleEvent(Settings.EventType.DEATH_LISTENER, Settings.EventPriority.NORMAL)) {
|
||||
handlePlayerDeath(event);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
default void onPlayerDeathLowest(@NotNull PlayerDeathEvent event) {
|
||||
if (handleEvent(Settings.EventType.DEATH_LISTENER, Settings.EventPriority.NORMAL)) {
|
||||
handlePlayerDeath(event);
|
||||
}
|
||||
}
|
||||
|
||||
void handlePlayerDeath(@NotNull PlayerDeathEvent player);
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package net.william278.husksync.listener;
|
||||
|
||||
import net.william278.husksync.config.Settings;
|
||||
import net.william278.husksync.player.BukkitPlayer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface BukkitJoinEventListener extends Listener {
|
||||
|
||||
boolean handleEvent(@NotNull Settings.EventType type, @NotNull Settings.EventPriority priority);
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
default void onPlayerJoinHighest(@NotNull PlayerJoinEvent event) {
|
||||
if (handleEvent(Settings.EventType.JOIN_LISTENER, Settings.EventPriority.HIGHEST)) {
|
||||
handlePlayerJoin(BukkitPlayer.adapt(event.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
default void onPlayerJoin(@NotNull PlayerJoinEvent event) {
|
||||
if (handleEvent(Settings.EventType.JOIN_LISTENER, Settings.EventPriority.NORMAL)) {
|
||||
handlePlayerJoin(BukkitPlayer.adapt(event.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
default void onPlayerJoinLowest(@NotNull PlayerJoinEvent event) {
|
||||
if (handleEvent(Settings.EventType.JOIN_LISTENER, Settings.EventPriority.NORMAL)) {
|
||||
handlePlayerJoin(BukkitPlayer.adapt(event.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
void handlePlayerJoin(@NotNull BukkitPlayer player);
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package net.william278.husksync.listener;
|
||||
|
||||
import net.william278.husksync.config.Settings;
|
||||
import net.william278.husksync.player.BukkitPlayer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface BukkitQuitEventListener extends Listener {
|
||||
|
||||
boolean handleEvent(@NotNull Settings.EventType type, @NotNull Settings.EventPriority priority);
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
default void onPlayerQuitHighest(@NotNull PlayerQuitEvent event) {
|
||||
if (handleEvent(Settings.EventType.QUIT_LISTENER, Settings.EventPriority.HIGHEST)) {
|
||||
handlePlayerQuit(BukkitPlayer.adapt(event.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
default void onPlayerQuit(@NotNull PlayerQuitEvent event) {
|
||||
if (handleEvent(Settings.EventType.QUIT_LISTENER, Settings.EventPriority.NORMAL)) {
|
||||
handlePlayerQuit(BukkitPlayer.adapt(event.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
default void onPlayerQuitLowest(@NotNull PlayerQuitEvent event) {
|
||||
if (handleEvent(Settings.EventType.QUIT_LISTENER, Settings.EventPriority.NORMAL)) {
|
||||
handlePlayerQuit(BukkitPlayer.adapt(event.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
void handlePlayerQuit(@NotNull BukkitPlayer player);
|
||||
|
||||
}
|
Loading…
Reference in New Issue