solved command parsing and message sent

This commit is contained in:
FeuSalamander 2023-05-11 14:59:01 +02:00
parent 003ff97a95
commit ff787c9b52
3 changed files with 48 additions and 7 deletions

View File

@ -6,7 +6,7 @@
<groupId>Vmessage</groupId> <groupId>Vmessage</groupId>
<artifactId>Vmessage</artifactId> <artifactId>Vmessage</artifactId>
<version>1.5.4</version> <version>1.5.5Pre</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Vmessage</name> <name>Vmessage</name>

View File

@ -56,13 +56,23 @@ public final class Listeners {
return; return;
} }
if(!configuration.getLeavecmd().isEmpty())for(String s : configuration.getLeavecmd()){proxyServer.getCommandManager().executeAsync(proxyServer.getConsoleCommandSource(), s);}
final Player p = e.getPlayer(); final Player p = e.getPlayer();
final Optional<ServerConnection> server = p.getCurrentServer(); final Optional<ServerConnection> server = p.getCurrentServer();
if (server.isEmpty()) { if (server.isEmpty()) {
return; return;
} }
String message = configuration.getLeaveFormat(); 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 message = message
.replace("#player#", p.getUsername()) .replace("#player#", p.getUsername())
.replace("#oldserver#", server.get().getServerInfo().getName()); .replace("#oldserver#", server.get().getServerInfo().getName());
@ -88,9 +98,20 @@ public final class Listeners {
if (!configuration.isChangeEnabled()) { if (!configuration.isChangeEnabled()) {
return; return;
} }
if(!configuration.getChangecmd().isEmpty())for(String s : configuration.getChangecmd()){proxyServer.getCommandManager().executeAsync(proxyServer.getConsoleCommandSource(), s);}
final ServerConnection actual = serverConnection.get(); final ServerConnection actual = serverConnection.get();
String message = configuration.getChangeFormat(); 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 message = message
.replace("#player#", p.getUsername()) .replace("#player#", p.getUsername())
.replace("#oldserver#", pre.getServerInfo().getName()) .replace("#oldserver#", pre.getServerInfo().getName())
@ -107,8 +128,18 @@ public final class Listeners {
if (!configuration.isJoinEnabled()) { if (!configuration.isJoinEnabled()) {
return; 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(); String message = configuration.getJoinFormat();
if(message.isEmpty())return;
message = message message = message
.replace("#player#", p.getUsername()) .replace("#player#", p.getUsername())
.replace("#server#", serverConnection.get().getServerInfo().getName()); .replace("#server#", serverConnection.get().getServerInfo().getName());
@ -136,9 +167,19 @@ public final class Listeners {
return message; return message;
} }
public void message(final Player p, final String m) { public void message(final Player p, final String m) {
if(!configuration.getMessagecmd().isEmpty())for(String s : configuration.getMessagecmd()){proxyServer.getCommandManager().executeAsync(proxyServer.getConsoleCommandSource(), s);} if(!configuration.getMessagecmd().isEmpty())
final boolean permission = p.hasPermission("vmessage.minimessage"); 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(); String message = configuration.getMessageFormat();
if(message.isEmpty())return;
final boolean permission = p.hasPermission("vmessage.minimessage");
message = message message = message
.replace("#player#", p.getUsername()) .replace("#player#", p.getUsername())
.replace("#server#", p.getCurrentServer().orElseThrow().getServerInfo().getName()); .replace("#server#", p.getCurrentServer().orElseThrow().getServerInfo().getName());

View File

@ -17,7 +17,7 @@ import java.nio.file.Path;
@Plugin( @Plugin(
id = "vmessage", id = "vmessage",
name = "Vmessage", name = "Vmessage",
version = "1.5.4", version = "1.5.5Pre",
description = "A velocity plugin that creates a multi server chat for the network", description = "A velocity plugin that creates a multi server chat for the network",
authors = {"FeuSalamander"}, authors = {"FeuSalamander"},
dependencies = { dependencies = {