added silent permission, added server aliases

This commit is contained in:
FeuSalamander 2023-08-20 09:31:55 +02:00
parent 68f4824593
commit fbb1d57d54
6 changed files with 58 additions and 20 deletions

View File

@ -12,4 +12,5 @@
- **MiniMessage support**
![](https://github.com/FeuSalamander/Vmessage/blob/main/src/main/resources/permissions.png?raw=true)
- **"vmessage.reload" to access to the reload command**
- **"vmessage.minimessage" the player need to have it to use MiniMessage in his messages**
- **"vmessage.minimessage" the player needs to have it to use MiniMessage in his messages**
- **"vmessage.silent. leave,change, join" if the player have it/them, no message will be sent**

View File

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

View File

@ -26,6 +26,7 @@ public final class Configuration {
private List<String> joincmd;
private List<String> leavecmd;
private List<String> changecmd;
private Toml aliases;
Configuration(Toml config) {
messageFormat = config.getString("Message.format", "");
@ -38,11 +39,12 @@ public final class Configuration {
leaveEnabled = config.getBoolean("Leave.enabled", false);
changeEnabled = config.getBoolean("Server-change.enabled", false);
aliases = config.getTable("Aliases");
messagecmd = config.getList("Message.commands");
joincmd = config.getList("Join.commands");
leavecmd = config.getList("Leave.commands");
changecmd = config.getList("Server-change.commands");
minimessage = config.getBoolean("Message-format.minimessage");
all = config.getBoolean("Message.all", false);
this.config = config;
@ -125,6 +127,9 @@ public final class Configuration {
public List<String> getChangecmd(){
return this.changecmd;
}
public Toml getAliases() {
return aliases;
}
void reload(){
config = config.read(file);
this.messageFormat = config.getString("Message.format");
@ -137,12 +142,14 @@ public final class Configuration {
this.leaveEnabled = config.getBoolean("Leave.enabled");
this.changeEnabled = config.getBoolean("Server-change.enabled");
messagecmd = config.getList("Message.commands");
joincmd = config.getList("Join.commands");
leavecmd = config.getList("Leave.commands");
changecmd = config.getList("Server-change.commands");
this.aliases = config.getTable("Aliases");
this.messagecmd = config.getList("Message.commands");
this.joincmd = config.getList("Join.commands");
this.leavecmd = config.getList("Leave.commands");
this.changecmd = config.getList("Server-change.commands");
this.minimessage = config.getBoolean("Message-format.minimessage");
all = config.getBoolean("Message.all", false);
this.all = config.getBoolean("Message.all", false);
}
}

View File

@ -55,18 +55,24 @@ public final class Listeners {
if (!e.getLoginStatus().equals(DisconnectEvent.LoginStatus.SUCCESSFUL_LOGIN)){
return;
}
if(e.getPlayer().hasPermission("vmessage.silent.leave")){
return;
}
final Player p = e.getPlayer();
final Optional<ServerConnection> server = p.getCurrentServer();
if (server.isEmpty()) {
return;
}
String message = configuration.getLeaveFormat();
String servername = server.get().getServerInfo().getName();
if(configuration.getAliases().contains(servername)){
servername = configuration.getAliases().getString(servername);
}
if(configuration.getLeavecmd() != null&&!configuration.getLeavecmd().isEmpty())
for(String s : configuration.getLeavecmd()){
s = s
.replace("#player#", p.getUsername())
.replace("#oldserver#", server.get().getServerInfo().getName());
.replace("#oldserver#", servername);
if (luckPermsAPI != null) {
s = luckperms(s, p);
}
@ -75,7 +81,7 @@ public final class Listeners {
if(message.isEmpty())return;
message = message
.replace("#player#", p.getUsername())
.replace("#oldserver#", server.get().getServerInfo().getName());
.replace("#oldserver#", servername);
if (luckPermsAPI != null) {
message = luckperms(message, p);
}
@ -98,14 +104,25 @@ public final class Listeners {
if (!configuration.isChangeEnabled()) {
return;
}
if(e.getPlayer().hasPermission("vmessage.silent.change")){
return;
}
final ServerConnection actual = serverConnection.get();
String message = configuration.getChangeFormat();
String actualservername = actual.getServerInfo().getName();
if(configuration.getAliases().contains(actualservername)){
actualservername = configuration.getAliases().getString(actualservername);
}
String oldservername = pre.getServerInfo().getName();
if(configuration.getAliases().containsTable(oldservername)){
oldservername = configuration.getAliases().getString(oldservername);
}
if(configuration.getChangecmd() != null&&!configuration.getChangecmd().isEmpty())
for(String s : configuration.getChangecmd()){
s = s
.replace("#player#", p.getUsername())
.replace("#oldserver#", pre.getServerInfo().getName())
.replace("#server#", actual.getServerInfo().getName());
.replace("#oldserver#", oldservername)
.replace("#server#", actualservername);
if (luckPermsAPI != null) {
s = luckperms(s, p);
}
@ -114,8 +131,8 @@ public final class Listeners {
if(message.isEmpty())return;
message = message
.replace("#player#", p.getUsername())
.replace("#oldserver#", pre.getServerInfo().getName())
.replace("#server#", actual.getServerInfo().getName());
.replace("#oldserver#", oldservername)
.replace("#server#", actualservername);
if (luckPermsAPI != null) {
message = luckperms(message, p);
}
@ -128,11 +145,18 @@ public final class Listeners {
if (!configuration.isJoinEnabled()) {
return;
}
if(e.getPlayer().hasPermission("vmessage.silent.join")){
return;
}
String actualservername = serverConnection.get().getServerInfo().getName();
if(configuration.getAliases().contains(actualservername)){
actualservername = configuration.getAliases().getString(actualservername);
}
if(configuration.getJoincmd() != null&&!configuration.getJoincmd().isEmpty())
for(String s : configuration.getJoincmd()){
s = s
.replace("#player#", p.getUsername())
.replace("#server#", serverConnection.get().getServerInfo().getName());
.replace("#server#", actualservername);
if (luckPermsAPI != null) {
s = luckperms(s, p);
}
@ -142,7 +166,7 @@ public final class Listeners {
if(message.isEmpty())return;
message = message
.replace("#player#", p.getUsername())
.replace("#server#", serverConnection.get().getServerInfo().getName());
.replace("#server#", actualservername);
if (luckPermsAPI != null) {
message = luckperms(message, p);
}
@ -167,11 +191,15 @@ public final class Listeners {
return message;
}
public void message(final Player p, final String m) {
String actualservername = p.getCurrentServer().orElseThrow().getServerInfo().getName();
if(configuration.getAliases().contains(actualservername)){
actualservername = configuration.getAliases().getString(actualservername);
}
if(configuration.getMessagecmd() != null&&!configuration.getMessagecmd().isEmpty())
for(String s : configuration.getMessagecmd()){
s = s
.replace("#player#", p.getUsername())
.replace("#server#", p.getCurrentServer().orElseThrow().getServerInfo().getName());
.replace("#server#", actualservername);
if (luckPermsAPI != null) {
s = luckperms(s, p);
}
@ -182,7 +210,7 @@ public final class Listeners {
final boolean permission = p.hasPermission("vmessage.minimessage");
message = message
.replace("#player#", p.getUsername())
.replace("#server#", p.getCurrentServer().orElseThrow().getServerInfo().getName());
.replace("#server#", actualservername);
if (luckPermsAPI != null) {
message = luckperms(message, p);
}

View File

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

View File

@ -41,3 +41,5 @@ enabled = true
format = "&7#prefix# #player# &eleft &c#oldserver# &eto join &a#server#"
commands = []
enabled = true
[Aliases]
servername = "Server Name"