Add PlayerJoinEvent to required linking

This commit is contained in:
Vankka 2024-07-07 12:34:10 +03:00
parent a0a5dd01fa
commit a3f7b448ac
No known key found for this signature in database
GPG Key ID: 62E48025ED4E7EBB
2 changed files with 15 additions and 2 deletions

View File

@ -30,7 +30,7 @@ public class BukkitRequiredLinkingConfig extends ServerRequiredLinkingConfig {
public static class KickOptions {
@Comment("The event to use for kick.\n"
+ "Available events: AsyncPlayerPreLoginEvent (preferred), PlayerLoginEvent")
+ "Available events: AsyncPlayerPreLoginEvent (preferred), PlayerLoginEvent, PlayerJoinEvent")
public String event = "AsyncPlayerPreLoginEvent";
@Comment("The event priority to use for the kick")

View File

@ -60,8 +60,9 @@ public class BukkitRequiredLinkingModule extends ServerRequireLinkingModule<Bukk
public void enable() {
super.enable();
register(PlayerLoginEvent.class, this::handle);
register(AsyncPlayerPreLoginEvent.class, this::handle);
register(PlayerLoginEvent.class, this::handle);
register(PlayerJoinEvent.class, this::handle);
discordSRV.server().getPluginManager().registerEvents(this, discordSRV.plugin());
}
@ -136,6 +137,18 @@ public class BukkitRequiredLinkingModule extends ServerRequireLinkingModule<Bukk
);
}
private void handle(PlayerJoinEvent event, EventPriority priority) {
Player player = event.getPlayer();
handle(
"PlayerJoinEvent",
priority,
player.getUniqueId(),
player.getName(),
() -> null,
player::kickPlayer
);
}
private void handle(
String eventType,
EventPriority priority,