From d9e7e89acc444e8a991ff00dc2a13ea03ed6ed20 Mon Sep 17 00:00:00 2001 From: Petr Ilin Date: Tue, 25 Jan 2022 15:43:56 +0300 Subject: Ability to set the prefix to offline/online players nickname 1.0.4-SNAPSHOT --- src/main/java/net/elytrium/limboauth/Settings.java | 4 ++++ .../java/net/elytrium/limboauth/listener/AuthListener.java | 12 ++++++++++++ 2 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/main/java/net/elytrium/limboauth/Settings.java b/src/main/java/net/elytrium/limboauth/Settings.java index bbae307..7903db4 100644 --- a/src/main/java/net/elytrium/limboauth/Settings.java +++ b/src/main/java/net/elytrium/limboauth/Settings.java @@ -62,6 +62,10 @@ public class Settings extends Config { public boolean TOTP_NEED_PASSWORD = true; public boolean REGISTER_NEED_REPEAT_PASSWORD = true; public boolean CHANGE_PASSWORD_NEED_OLD_PASSWORD = true; + @Comment("This prefix will be added to offline mode players nickname") + public String OFFLINE_MODE_PREFIX = ""; + @Comment("This prefix will be added to online mode players nickname") + public String ONLINE_MODE_PREFIX = ""; @Comment({ "If you want to migrate your database from another plugin, which is not using BCrypt.", "You can set an old hash algorithm to migrate from. Currently, only AUTHME is supported yet." diff --git a/src/main/java/net/elytrium/limboauth/listener/AuthListener.java b/src/main/java/net/elytrium/limboauth/listener/AuthListener.java index 70dca80..59ab50d 100644 --- a/src/main/java/net/elytrium/limboauth/listener/AuthListener.java +++ b/src/main/java/net/elytrium/limboauth/listener/AuthListener.java @@ -124,5 +124,17 @@ public class AuthListener { if (Settings.IMP.MAIN.FORCE_OFFLINE_UUID) { event.setGameProfile(event.getOriginalProfile().withId(UuidUtils.generateOfflinePlayerUuid(event.getUsername()))); } + + if (!event.isOnlineMode() && !Settings.IMP.MAIN.OFFLINE_MODE_PREFIX.isEmpty()) { + event.setGameProfile(event.getOriginalProfile().withName( + Settings.IMP.MAIN.OFFLINE_MODE_PREFIX + event.getUsername() + )); + } + + if (event.isOnlineMode() && !Settings.IMP.MAIN.ONLINE_MODE_PREFIX.isEmpty()) { + event.setGameProfile(event.getOriginalProfile().withName( + Settings.IMP.MAIN.ONLINE_MODE_PREFIX + event.getUsername() + )); + } } } -- cgit