Skip to content

Commit

Permalink
feat: prevent login if player has bad name
Browse files Browse the repository at this point in the history
  • Loading branch information
acrylic-style committed Jan 15, 2024
1 parent a529bc6 commit fb0f234
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "net.azisaba"
version = "6.8.2"
version = "6.8.3"

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;

public class PlayerJoinListener implements Listener {
private final LifeCore plugin;
Expand Down Expand Up @@ -36,4 +37,14 @@ public void onPlayerJoin(PlayerJoinEvent e) {
PlayerUtil.getChannel(e.getPlayer()).pipeline()
.addBefore("packet_handler", "lifecore", new PacketHandler(e.getPlayer()));
}

@EventHandler
public void onPlayerLogin(PlayerLoginEvent e) {
if (!Bukkit.getPluginManager().isPluginEnabled("Towny")) {
return;
}
if (e.getPlayer().getName().toLowerCase().startsWith("town_") || e.getPlayer().getName().toLowerCase().startsWith("nation_")) {
e.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Towny is preventing you from logging in using this account name.");
}
}
}

0 comments on commit fb0f234

Please sign in to comment.