added the commands

This commit is contained in:
FeuSalamander 2023-05-10 17:05:01 +02:00
parent c0d3bc7d50
commit 75da02bd26
5 changed files with 40 additions and 33 deletions

18
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>Vmessage</groupId>
<artifactId>Vmessage</artifactId>
<version>1.5.3</version>
<version>1.5.4</version>
<packaging>jar</packaging>
<name>Vmessage</name>
@ -25,7 +25,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-sources</id>
@ -38,7 +38,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.1</version>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
@ -141,7 +141,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.5.0</version>
<version>3.2.0</version>
</plugin>
</plugins>
</reporting>
@ -151,10 +151,6 @@
<id>papermc-repo</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
@ -170,11 +166,5 @@
<version>5.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.william278</groupId>
<artifactId>PAPIProxyBridge</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -6,6 +6,7 @@ import java.io.File;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Objects;
public final class Configuration {
@ -21,6 +22,10 @@ public final class Configuration {
private boolean all;
private Toml config;
private static File file;
private List<String> messagecmd;
private List<String> joincmd;
private List<String> leavecmd;
private List<String> changecmd;
Configuration(Toml config) {
messageFormat = config.getString("Message.format", "");
@ -33,6 +38,11 @@ public final class Configuration {
leaveEnabled = config.getBoolean("Leave.enabled", false);
changeEnabled = config.getBoolean("Server-change.enabled", false);
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;
@ -103,6 +113,18 @@ public final class Configuration {
public boolean isAllEnabled(){
return this.all;
}
public List<String> getMessagecmd(){
return this.messagecmd;
}
public List<String> getJoincmd(){
return this.joincmd;
}
public List<String> getLeavecmd(){
return this.leavecmd;
}
public List<String> getChangecmd(){
return this.changecmd;
}
void reload(){
config = config.read(file);
this.messageFormat = config.getString("Message.format");
@ -115,6 +137,11 @@ 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.minimessage = config.getBoolean("Message-format.minimessage");
all = config.getBoolean("Message.all", false);
}

View File

@ -14,13 +14,9 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.LuckPermsProvider;
import net.luckperms.api.cacheddata.CachedMetaData;
import net.william278.papiproxybridge.api.PlaceholderAPI;
import net.william278.papiproxybridge.user.OnlineUser;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
@SuppressWarnings({"UnstableApiUsage", "deprecation"})
public final class Listeners {
@ -30,7 +26,6 @@ public final class Listeners {
.build();
public static final MiniMessage mm = MiniMessage.miniMessage();
private LuckPerms luckPermsAPI;
private PlaceholderAPI placeholderAPI;
private final Configuration configuration;
private final ProxyServer proxyServer;
@ -38,9 +33,6 @@ public final class Listeners {
if (proxyServer.getPluginManager().getPlugin("luckperms").isPresent()) {
this.luckPermsAPI = LuckPermsProvider.get();
}
if (proxyServer.getPluginManager().getPlugin("papiproxybridge").isPresent()) {
this.placeholderAPI = PlaceholderAPI.getInstance();
}
this.configuration = configuration;
this.proxyServer = proxyServer;
}
@ -59,13 +51,13 @@ public final class Listeners {
if (!configuration.isLeaveEnabled()) {
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();
message = placeholder(message, p);
message = message
.replace("#player#", p.getUsername())
.replace("#oldserver#", server.get().getServerInfo().getName());
@ -91,9 +83,9 @@ 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();
message = placeholder(message, p);
message = message
.replace("#player#", p.getUsername())
.replace("#oldserver#", pre.getServerInfo().getName())
@ -110,8 +102,8 @@ public final class Listeners {
if (!configuration.isJoinEnabled()) {
return;
}
if(!configuration.getJoincmd().isEmpty())for(String s : configuration.getJoincmd()){proxyServer.getCommandManager().executeAsync(proxyServer.getConsoleCommandSource(), s);}
String message = configuration.getJoinFormat();
message = placeholder(message, p);
message = message
.replace("#player#", p.getUsername())
.replace("#server#", serverConnection.get().getServerInfo().getName());
@ -138,16 +130,10 @@ public final class Listeners {
message = message.replace("#prefix#", "").replace("#suffix#", "");
return message;
}
private String placeholder(String message, final Player player){
if(placeholderAPI == null)return message;
UUID p = player.getUniqueId();
placeholderAPI.formatPlaceholders("Hello %player_name%!", p).thenAccept(formatedd -> {proxyServer.sendMessage(Component.text("test: "+formatedd));});
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");
String message = configuration.getMessageFormat();
message = placeholder(message, p);
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.3",
version = "1.5.4",
description = "A velocity plugin that creates a multi server chat for the network",
authors = {"FeuSalamander"},
dependencies = {

View File

@ -11,6 +11,7 @@ minimessage = false
#- "#server#" : return the player's server name
format = "&a(#server#) #prefix# #player# &8&l> &r#message#"
all = false #if the formated message is sent even in the server where the player is located (can cause some issues with other plugins)
commands = []
enabled = true
[Join]
#place holders:
@ -19,6 +20,7 @@ enabled = true
#- "#prefix#" : return the player's luckperms prefix
#- "#suffix#" : return the player's luckperms suffix
format = "&7#prefix# #player# &ejoined &7#server#"
commands = [] #The proxy commands which are executed (no / in the commands)
enabled = true
[Leave]
#place holders:
@ -27,6 +29,7 @@ enabled = true
#- "#prefix#" : return the player's luckperms prefix
#- "#suffix#" : return the player's luckperms suffix
format = "#&7prefix# #player# &eleft &7#oldserver#"
commands = []
enabled = true
[Server-change]
#place holders:
@ -36,4 +39,5 @@ enabled = true
#- "#oldserver#" : return the previous player's server name
#- "#server#" : return the new player's server name
format = "&7#prefix# #player# &eleft &c#oldserver# &eto join &a#server#"
commands = []
enabled = true