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

View File

@ -6,6 +6,7 @@ import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List;
import java.util.Objects; import java.util.Objects;
public final class Configuration { public final class Configuration {
@ -21,6 +22,10 @@ public final class Configuration {
private boolean all; private boolean all;
private Toml config; private Toml config;
private static File file; private static File file;
private List<String> messagecmd;
private List<String> joincmd;
private List<String> leavecmd;
private List<String> changecmd;
Configuration(Toml config) { Configuration(Toml config) {
messageFormat = config.getString("Message.format", ""); messageFormat = config.getString("Message.format", "");
@ -33,6 +38,11 @@ public final class Configuration {
leaveEnabled = config.getBoolean("Leave.enabled", false); leaveEnabled = config.getBoolean("Leave.enabled", false);
changeEnabled = config.getBoolean("Server-change.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"); minimessage = config.getBoolean("Message-format.minimessage");
all = config.getBoolean("Message.all", false); all = config.getBoolean("Message.all", false);
this.config = config; this.config = config;
@ -103,6 +113,18 @@ public final class Configuration {
public boolean isAllEnabled(){ public boolean isAllEnabled(){
return this.all; 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(){ void reload(){
config = config.read(file); config = config.read(file);
this.messageFormat = config.getString("Message.format"); this.messageFormat = config.getString("Message.format");
@ -115,6 +137,11 @@ public final class Configuration {
this.leaveEnabled = config.getBoolean("Leave.enabled"); this.leaveEnabled = config.getBoolean("Leave.enabled");
this.changeEnabled = config.getBoolean("Server-change.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"); this.minimessage = config.getBoolean("Message-format.minimessage");
all = config.getBoolean("Message.all", false); 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.LuckPerms;
import net.luckperms.api.LuckPermsProvider; import net.luckperms.api.LuckPermsProvider;
import net.luckperms.api.cacheddata.CachedMetaData; 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.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
@SuppressWarnings({"UnstableApiUsage", "deprecation"}) @SuppressWarnings({"UnstableApiUsage", "deprecation"})
public final class Listeners { public final class Listeners {
@ -30,7 +26,6 @@ public final class Listeners {
.build(); .build();
public static final MiniMessage mm = MiniMessage.miniMessage(); public static final MiniMessage mm = MiniMessage.miniMessage();
private LuckPerms luckPermsAPI; private LuckPerms luckPermsAPI;
private PlaceholderAPI placeholderAPI;
private final Configuration configuration; private final Configuration configuration;
private final ProxyServer proxyServer; private final ProxyServer proxyServer;
@ -38,9 +33,6 @@ public final class Listeners {
if (proxyServer.getPluginManager().getPlugin("luckperms").isPresent()) { if (proxyServer.getPluginManager().getPlugin("luckperms").isPresent()) {
this.luckPermsAPI = LuckPermsProvider.get(); this.luckPermsAPI = LuckPermsProvider.get();
} }
if (proxyServer.getPluginManager().getPlugin("papiproxybridge").isPresent()) {
this.placeholderAPI = PlaceholderAPI.getInstance();
}
this.configuration = configuration; this.configuration = configuration;
this.proxyServer = proxyServer; this.proxyServer = proxyServer;
} }
@ -59,13 +51,13 @@ public final class Listeners {
if (!configuration.isLeaveEnabled()) { if (!configuration.isLeaveEnabled()) {
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();
message = placeholder(message, p);
message = message message = message
.replace("#player#", p.getUsername()) .replace("#player#", p.getUsername())
.replace("#oldserver#", server.get().getServerInfo().getName()); .replace("#oldserver#", server.get().getServerInfo().getName());
@ -91,9 +83,9 @@ 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();
message = placeholder(message, p);
message = message message = message
.replace("#player#", p.getUsername()) .replace("#player#", p.getUsername())
.replace("#oldserver#", pre.getServerInfo().getName()) .replace("#oldserver#", pre.getServerInfo().getName())
@ -110,8 +102,8 @@ 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);}
String message = configuration.getJoinFormat(); String message = configuration.getJoinFormat();
message = placeholder(message, p);
message = message message = message
.replace("#player#", p.getUsername()) .replace("#player#", p.getUsername())
.replace("#server#", serverConnection.get().getServerInfo().getName()); .replace("#server#", serverConnection.get().getServerInfo().getName());
@ -138,16 +130,10 @@ public final class Listeners {
message = message.replace("#prefix#", "").replace("#suffix#", ""); message = message.replace("#prefix#", "").replace("#suffix#", "");
return message; 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) { 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"); final boolean permission = p.hasPermission("vmessage.minimessage");
String message = configuration.getMessageFormat(); String message = configuration.getMessageFormat();
message = placeholder(message, p);
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.3", version = "1.5.4",
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 = {

View File

@ -11,6 +11,7 @@ minimessage = false
#- "#server#" : return the player's server name #- "#server#" : return the player's server name
format = "&a(#server#) #prefix# #player# &8&l> &r#message#" 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) 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 enabled = true
[Join] [Join]
#place holders: #place holders:
@ -19,6 +20,7 @@ enabled = true
#- "#prefix#" : return the player's luckperms prefix #- "#prefix#" : return the player's luckperms prefix
#- "#suffix#" : return the player's luckperms suffix #- "#suffix#" : return the player's luckperms suffix
format = "&7#prefix# #player# &ejoined &7#server#" format = "&7#prefix# #player# &ejoined &7#server#"
commands = [] #The proxy commands which are executed (no / in the commands)
enabled = true enabled = true
[Leave] [Leave]
#place holders: #place holders:
@ -27,6 +29,7 @@ enabled = true
#- "#prefix#" : return the player's luckperms prefix #- "#prefix#" : return the player's luckperms prefix
#- "#suffix#" : return the player's luckperms suffix #- "#suffix#" : return the player's luckperms suffix
format = "#&7prefix# #player# &eleft &7#oldserver#" format = "#&7prefix# #player# &eleft &7#oldserver#"
commands = []
enabled = true enabled = true
[Server-change] [Server-change]
#place holders: #place holders:
@ -36,4 +39,5 @@ enabled = true
#- "#oldserver#" : return the previous player's server name #- "#oldserver#" : return the previous player's server name
#- "#server#" : return the new player's server name #- "#server#" : return the new player's server name
format = "&7#prefix# #player# &eleft &c#oldserver# &eto join &a#server#" format = "&7#prefix# #player# &eleft &c#oldserver# &eto join &a#server#"
commands = []
enabled = true enabled = true