From ad3feaec66ba35223bea2a334fd012c5fce67992 Mon Sep 17 00:00:00 2001 From: unilock Date: Wed, 15 Mar 2023 09:21:28 -0400 Subject: [PATCH] allow using server name in join and leave messages Signed-off-by: unilock --- src/main/java/me/feusalamander/vmessage/Listeners.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/feusalamander/vmessage/Listeners.java b/src/main/java/me/feusalamander/vmessage/Listeners.java index af9b4be..ecc9cee 100644 --- a/src/main/java/me/feusalamander/vmessage/Listeners.java +++ b/src/main/java/me/feusalamander/vmessage/Listeners.java @@ -53,11 +53,13 @@ public final class Listeners { return; } Player p = e.getPlayer(); - if (p.getCurrentServer().isEmpty()) { + Optional server = p.getCurrentServer(); + if (server.isEmpty()) { return; } String message = configuration.getLeaveFormat() - .replace("#player#", p.getUsername()); + .replace("#player#", p.getUsername()) + .replace("#oldserver#", server.get().getServerInfo().getName()); if (luckPermsAPI != null) { message = luckperms(message, p); } @@ -98,7 +100,9 @@ public final class Listeners { if (!configuration.isJoinEnabled()) { return; } - String message = configuration.getJoinFormat().replace("#player#", p.getUsername()); + String message = configuration.getJoinFormat() + .replace("#player#", p.getUsername()) + .replace("#server#", actual.getServerInfo().getName()); if (luckPermsAPI != null) { message = luckperms(message, p); }