From ff787c9b524c38d6f2524d672e1d68e88a2e4577 Mon Sep 17 00:00:00 2001 From: FeuSalamander Date: Thu, 11 May 2023 14:59:01 +0200 Subject: [PATCH] solved command parsing and message sent --- pom.xml | 2 +- .../me/feusalamander/vmessage/Listeners.java | 51 +++++++++++++++++-- .../me/feusalamander/vmessage/VMessage.java | 2 +- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 6a961d6..927a240 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ Vmessage Vmessage - 1.5.4 + 1.5.5Pre jar Vmessage diff --git a/src/main/java/me/feusalamander/vmessage/Listeners.java b/src/main/java/me/feusalamander/vmessage/Listeners.java index 1ba1247..92f543f 100644 --- a/src/main/java/me/feusalamander/vmessage/Listeners.java +++ b/src/main/java/me/feusalamander/vmessage/Listeners.java @@ -56,13 +56,23 @@ public final class Listeners { return; } - if(!configuration.getLeavecmd().isEmpty())for(String s : configuration.getLeavecmd()){proxyServer.getCommandManager().executeAsync(proxyServer.getConsoleCommandSource(), s);} final Player p = e.getPlayer(); final Optional server = p.getCurrentServer(); if (server.isEmpty()) { return; } String message = configuration.getLeaveFormat(); + if(!configuration.getLeavecmd().isEmpty()) + for(String s : configuration.getLeavecmd()){ + s = s + .replace("#player#", p.getUsername()) + .replace("#oldserver#", server.get().getServerInfo().getName()); + if (luckPermsAPI != null) { + s = luckperms(s, p); + } + proxyServer.getCommandManager().executeAsync(proxyServer.getConsoleCommandSource(), s); + } + if(message.isEmpty())return; message = message .replace("#player#", p.getUsername()) .replace("#oldserver#", server.get().getServerInfo().getName()); @@ -88,9 +98,20 @@ public final class Listeners { if (!configuration.isChangeEnabled()) { return; } - if(!configuration.getChangecmd().isEmpty())for(String s : configuration.getChangecmd()){proxyServer.getCommandManager().executeAsync(proxyServer.getConsoleCommandSource(), s);} final ServerConnection actual = serverConnection.get(); String message = configuration.getChangeFormat(); + if(!configuration.getChangecmd().isEmpty()) + for(String s : configuration.getChangecmd()){ + s = s + .replace("#player#", p.getUsername()) + .replace("#oldserver#", pre.getServerInfo().getName()) + .replace("#server#", actual.getServerInfo().getName()); + if (luckPermsAPI != null) { + s = luckperms(s, p); + } + proxyServer.getCommandManager().executeAsync(proxyServer.getConsoleCommandSource(), s); + } + if(message.isEmpty())return; message = message .replace("#player#", p.getUsername()) .replace("#oldserver#", pre.getServerInfo().getName()) @@ -107,8 +128,18 @@ public final class Listeners { if (!configuration.isJoinEnabled()) { return; } - if(!configuration.getJoincmd().isEmpty())for(String s : configuration.getJoincmd()){proxyServer.getCommandManager().executeAsync(proxyServer.getConsoleCommandSource(), s);} + if(!configuration.getJoincmd().isEmpty()) + for(String s : configuration.getJoincmd()){ + s = s + .replace("#player#", p.getUsername()) + .replace("#server#", serverConnection.get().getServerInfo().getName()); + if (luckPermsAPI != null) { + s = luckperms(s, p); + } + proxyServer.getCommandManager().executeAsync(proxyServer.getConsoleCommandSource(), s); + } String message = configuration.getJoinFormat(); + if(message.isEmpty())return; message = message .replace("#player#", p.getUsername()) .replace("#server#", serverConnection.get().getServerInfo().getName()); @@ -136,9 +167,19 @@ public final class Listeners { return message; } public void message(final Player p, final String m) { - if(!configuration.getMessagecmd().isEmpty())for(String s : configuration.getMessagecmd()){proxyServer.getCommandManager().executeAsync(proxyServer.getConsoleCommandSource(), s);} - final boolean permission = p.hasPermission("vmessage.minimessage"); + if(!configuration.getMessagecmd().isEmpty()) + for(String s : configuration.getMessagecmd()){ + s = s + .replace("#player#", p.getUsername()) + .replace("#server#", p.getCurrentServer().orElseThrow().getServerInfo().getName()); + if (luckPermsAPI != null) { + s = luckperms(s, p); + } + proxyServer.getCommandManager().executeAsync(proxyServer.getConsoleCommandSource(), s); + } String message = configuration.getMessageFormat(); + if(message.isEmpty())return; + final boolean permission = p.hasPermission("vmessage.minimessage"); message = message .replace("#player#", p.getUsername()) .replace("#server#", p.getCurrentServer().orElseThrow().getServerInfo().getName()); diff --git a/src/main/java/me/feusalamander/vmessage/VMessage.java b/src/main/java/me/feusalamander/vmessage/VMessage.java index 96d3305..4c36081 100644 --- a/src/main/java/me/feusalamander/vmessage/VMessage.java +++ b/src/main/java/me/feusalamander/vmessage/VMessage.java @@ -17,7 +17,7 @@ import java.nio.file.Path; @Plugin( id = "vmessage", name = "Vmessage", - version = "1.5.4", + version = "1.5.5Pre", description = "A velocity plugin that creates a multi server chat for the network", authors = {"FeuSalamander"}, dependencies = {