aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/net/elytrium/limboauth/LimboAuth.java8
-rw-r--r--src/main/java/net/elytrium/limboauth/Settings.java5
2 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/net/elytrium/limboauth/LimboAuth.java b/src/main/java/net/elytrium/limboauth/LimboAuth.java
index d0345fc..b52c32f 100644
--- a/src/main/java/net/elytrium/limboauth/LimboAuth.java
+++ b/src/main/java/net/elytrium/limboauth/LimboAuth.java
@@ -150,6 +150,7 @@ public class LimboAuth {
private Component loginFloodgate;
@Nullable
private Title loginFloodgateTitle;
+ private Component registrationsDisabledKick;
private Component nicknameInvalidKick;
private ScheduledTask purgeCacheTask;
private ScheduledTask purgePremiumCacheTask;
@@ -246,6 +247,7 @@ public class LimboAuth {
}
this.nicknameInvalidKick = SERIALIZER.deserialize(Settings.IMP.MAIN.STRINGS.NICKNAME_INVALID_KICK);
+ this.registrationsDisabledKick = SERIALIZER.deserialize(Settings.IMP.MAIN.STRINGS.REGISTRATIONS_DISABLED_KICK);
if (Settings.IMP.MAIN.CHECK_PASSWORD_STRENGTH) {
this.unsafePasswords.clear();
@@ -484,6 +486,7 @@ public class LimboAuth {
String nickname = player.getUsername();
if (this.nicknameValidationPattern.matcher((isFloodgate) ? nickname.substring(this.floodgateApi.getPrefixLength()) : nickname).matches()) {
RegisteredPlayer registeredPlayer = AuthSessionHandler.fetchInfo(this.playerDao, nickname);
+
boolean onlineMode = player.isOnlineMode();
TaskEvent.Result result = TaskEvent.Result.NORMAL;
@@ -518,6 +521,11 @@ public class LimboAuth {
EventManager eventManager = this.server.getEventManager();
if (registeredPlayer == null) {
+ if (Settings.IMP.MAIN.DISABLE_REGISTRATIONS) {
+ player.disconnect(this.registrationsDisabledKick);
+ return;
+ }
+
Consumer<TaskEvent> eventConsumer = (event) -> this.sendPlayer(event, null);
eventManager.fire(new PreRegisterEvent(eventConsumer, result, player)).thenAcceptAsync(eventConsumer);
} else {
diff --git a/src/main/java/net/elytrium/limboauth/Settings.java b/src/main/java/net/elytrium/limboauth/Settings.java
index 7a1a29c..a777f5d 100644
--- a/src/main/java/net/elytrium/limboauth/Settings.java
+++ b/src/main/java/net/elytrium/limboauth/Settings.java
@@ -156,6 +156,9 @@ public class Settings extends YamlConfig {
public List<String> LOGIN_COMMAND = List.of("/l", "/log", "/login");
public List<String> TOTP_COMMAND = List.of("/2fa", "/totp");
+ @Comment("New players will be kicked with registrations-disabled-kick message")
+ public boolean DISABLE_REGISTRATIONS = false;
+
@Create
public Settings.MAIN.WORLD_COORDS WORLD_COORDS;
@@ -289,6 +292,8 @@ public class Settings extends YamlConfig {
public String FORCE_UNREGISTER_NOT_SUCCESSFUL = "{PRFX} &cUnable to unregister &6{0}&c. Most likely this player has never been on this server.";
public String FORCE_UNREGISTER_USAGE = "{PRFX} Usage: &6/forceunregister <nickname>";
+ public String REGISTRATIONS_DISABLED_KICK = "{PRFX} Registrations are currently disabled.";
+
public String CHANGE_PASSWORD_SUCCESSFUL = "{PRFX} &aSuccessfully changed password!";
@Comment("Or if change-password-need-old-pass set to false remove the \"<old password>\" part.")
public String CHANGE_PASSWORD_USAGE = "{PRFX} Usage: &6/changepassword <old password> <new password>";