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>
<artifactId>Vmessage</artifactId>
<version>1.5.4</version>
<version>1.5.5Pre</version>
<packaging>jar</packaging>
<name>Vmessage</name>

View File

@ -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<ServerConnection> 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());

View File

@ -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 = {