Compare commits

..

No commits in common. "b06c38a27133efddffcbcbba40875050bc3674f7" and "68f4824593d8590b5a8a41ab9e22a1d4c58e12ed" have entirely different histories.

10 changed files with 162 additions and 170 deletions

View File

@ -1,14 +1,15 @@
# Vmessage fork
**Join/leave/change messages**
## Features
- **3 Events with custom messages for each**
![](https://github.com/FeuSalamander/Vmessage/blob/main/src/main/resources/Vmessage_desc.jpg?raw=true)
**Ever wanted to have your messages sent globally across your Velocity proxy with LuckPerms ranks ? Here's a simple plugin to do just that!**
![](https://github.com/FeuSalamander/Vmessage/blob/main/src/main/resources/features.png?raw=true)
- **4 Events with custom messages for each**
- **Player Message**
- **Player join the network**
- **Player left the network**
- **Player server change**
- **LuckPerms Prefix and Suffix Support**
- **Reload command: "/vmessage reload"**
- **Global message command: "/sendall"**
- **MiniMessage support**
## Permissions
![](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 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**
- **"vmessage.minimessage" the player need to have it to use MiniMessage in his messages**

View File

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

View File

@ -10,46 +10,41 @@ import java.util.List;
import java.util.Objects;
public final class Configuration {
private String messageFormat;
private String joinFormat;
private String leaveFormat;
private String kickFormat;
private String changeFormat;
private boolean messageEnabled;
private boolean joinEnabled;
private boolean leaveEnabled;
private boolean kickEnabled;
private boolean changeEnabled;
private boolean minimessage;
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> kickcmd;
private List<String> changecmd;
private String custom1;
private String custom2;
private Toml aliases;
Configuration(Toml config) {
messageFormat = config.getString("Message.format", "");
joinFormat = config.getString("Join.format", "");
leaveFormat = config.getString("Leave.format", "");
kickFormat = config.getString("Kick.format", "");
changeFormat = config.getString("Server-change.format", "");
messageEnabled = config.getBoolean("Message.enabled", false);
joinEnabled = config.getBoolean("Join.enabled", false);
leaveEnabled = config.getBoolean("Leave.enabled", false);
kickEnabled = config.getBoolean("Kick.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");
kickcmd = config.getList("Kick.commands");
changecmd = config.getList("Server-change.commands");
minimessage = config.getBoolean("Message-format.minimessage");
custom1 = config.getString("Custom-Meta.custom1", "");
custom2 = config.getString("Custom-Meta.custom2", "");
minimessage = config.getBoolean("Message-format.minimessage");
all = config.getBoolean("Message.all", false);
this.config = config;
}
@ -81,6 +76,10 @@ public final class Configuration {
}
}
public String getMessageFormat() {
return this.messageFormat;
}
public String getJoinFormat() {
return this.joinFormat;
}
@ -88,14 +87,15 @@ public final class Configuration {
public String getLeaveFormat() {
return this.leaveFormat;
}
public String getKickFormat() {
return this.kickFormat;
}
public String getChangeFormat() {
return this.changeFormat;
}
public boolean isMessageEnabled() {
return this.messageEnabled;
}
public boolean isJoinEnabled() {
return this.joinEnabled;
}
@ -103,9 +103,6 @@ public final class Configuration {
public boolean isLeaveEnabled() {
return this.leaveEnabled;
}
public boolean isKickEnabled() {
return this.kickEnabled;
}
public boolean isChangeEnabled() {
return this.changeEnabled;
@ -113,50 +110,39 @@ public final class Configuration {
public boolean isMinimessageEnabled(){
return this.minimessage;
}
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> getKickcmd(){
return this.kickcmd;
}
public List<String> getChangecmd(){
return this.changecmd;
}
public Toml getAliases() {
return aliases;
}
public String getCustom1() {
return this.custom1;
}
public String getCustom2() {
return this.custom2;
}
void reload(){
config = config.read(file);
this.messageFormat = config.getString("Message.format");
this.joinFormat = config.getString("Join.format");
this.leaveFormat = config.getString("Leave.format");
this.kickFormat = config.getString("Kick.format");
this.changeFormat = config.getString("Server-change.format");
this.messageEnabled = config.getBoolean("Message.enabled");
this.joinEnabled = config.getBoolean("Join.enabled");
this.leaveEnabled = config.getBoolean("Leave.enabled");
this.kickEnabled = config.getBoolean("Kick.enabled");
this.changeEnabled = config.getBoolean("Server-change.enabled");
this.aliases = config.getTable("Aliases");
this.joincmd = config.getList("Join.commands");
this.leavecmd = config.getList("Leave.commands");
this.kickcmd = config.getList("Kick.commands");
this.changecmd = config.getList("Server-change.commands");
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.custom1 = config.getString("Custom-Meta.custom1");
this.custom2 = config.getString("Custom-Meta.custom2");
all = config.getBoolean("Message.all", false);
}
}

View File

@ -2,7 +2,6 @@ package me.feusalamander.vmessage;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.DisconnectEvent;
import com.velocitypowered.api.event.player.KickedFromServerEvent;
import com.velocitypowered.api.event.player.PlayerChatEvent;
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
import com.velocitypowered.api.proxy.Player;
@ -16,7 +15,6 @@ import net.luckperms.api.LuckPerms;
import net.luckperms.api.LuckPermsProvider;
import net.luckperms.api.cacheddata.CachedMetaData;
import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
@ -38,33 +36,37 @@ public final class Listeners {
this.configuration = configuration;
this.proxyServer = proxyServer;
}
@Subscribe
private void onMessage(final PlayerChatEvent e) {
if (!configuration.isMessageEnabled()) {
return;
}
if(configuration.isAllEnabled()){
e.setResult(PlayerChatEvent.ChatResult.denied());
}
message(e.getPlayer(), e.getMessage());
}
@Subscribe
private void onLeave(final DisconnectEvent e) {
if (!configuration.isLeaveEnabled()) {
return;
}
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#", servername);
.replace("#oldserver#", server.get().getServerInfo().getName());
if (luckPermsAPI != null) {
s = luckperms(s, p);
}
@ -73,49 +75,7 @@ public final class Listeners {
if(message.isEmpty())return;
message = message
.replace("#player#", p.getUsername())
.replace("#oldserver#", servername);
if (luckPermsAPI != null) {
message = luckperms(message, p);
}
if (configuration.isMinimessageEnabled()) {
proxyServer.sendMessage(mm.deserialize(message.replace("§", "")));
} else {
proxyServer.sendMessage(SERIALIZER.deserialize(message));
}
}
@Subscribe
private void onKick(final KickedFromServerEvent e) {
if (!configuration.isKickEnabled()) {
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.getKickFormat();
String servername = server.get().getServerInfo().getName();
if(configuration.getAliases().contains(servername)){
servername = configuration.getAliases().getString(servername);
}
if(configuration.getKickcmd() != null&&!configuration.getKickcmd().isEmpty())
for(String s : configuration.getKickcmd()){
s = s
.replace("#player#", p.getUsername())
.replace("#oldserver#", servername);
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#", servername);
.replace("#oldserver#", server.get().getServerInfo().getName());
if (luckPermsAPI != null) {
message = luckperms(message, p);
}
@ -138,25 +98,14 @@ 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#", oldservername)
.replace("#server#", actualservername);
.replace("#oldserver#", pre.getServerInfo().getName())
.replace("#server#", actual.getServerInfo().getName());
if (luckPermsAPI != null) {
s = luckperms(s, p);
}
@ -165,8 +114,8 @@ public final class Listeners {
if(message.isEmpty())return;
message = message
.replace("#player#", p.getUsername())
.replace("#oldserver#", oldservername)
.replace("#server#", actualservername);
.replace("#oldserver#", pre.getServerInfo().getName())
.replace("#server#", actual.getServerInfo().getName());
if (luckPermsAPI != null) {
message = luckperms(message, p);
}
@ -179,18 +128,11 @@ 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#", actualservername);
.replace("#server#", serverConnection.get().getServerInfo().getName());
if (luckPermsAPI != null) {
s = luckperms(s, p);
}
@ -200,7 +142,7 @@ public final class Listeners {
if(message.isEmpty())return;
message = message
.replace("#player#", p.getUsername())
.replace("#server#", actualservername);
.replace("#server#", serverConnection.get().getServerInfo().getName());
if (luckPermsAPI != null) {
message = luckperms(message, p);
}
@ -215,22 +157,53 @@ public final class Listeners {
final CachedMetaData data = luckPermsAPI.getPlayerAdapter(Player.class).getMetaData(p);
final String prefix = data.getPrefix();
final String suffix = data.getSuffix();
final String custom1 = data.getMetaValue(configuration.getCustom1());
final String custom2 = data.getMetaValue(configuration.getCustom2());
if (message.contains("#prefix#") && prefix != null) {
if (message.contains("#prefix#")&&prefix != null) {
message = message.replace("#prefix#", prefix);
}
if (message.contains("#suffix#") && suffix != null) {
if (message.contains("#suffix#")&&suffix != null) {
message = message.replace("#suffix#", suffix);
}
if (message.contains("#custom1#") && custom1 != null) {
message = message.replace("#custom1#", custom1);
}
if (message.contains("#custom2#") && custom2 != null) {
message = message.replace("#custom2#", custom2);
}
message = message.replace("#prefix#", "").replace("#suffix#", "").replace("#custom1#","").replace("#custom2#","");
message = message.replace("#prefix#", "").replace("#suffix#", "");
return message;
}
public void message(final Player p, final String m) {
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());
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());
if (luckPermsAPI != null) {
message = luckperms(message, p);
}
if(permission)message = message.replace("#message#", m);
Component finalMessage;
if (configuration.isMinimessageEnabled()) {
finalMessage = mm.deserialize(message.replace("§", ""));
} else {
finalMessage = SERIALIZER.deserialize(message);
}
if(!permission)finalMessage = finalMessage.replaceText("#message#", Component.text(m));
if(configuration.isAllEnabled()){
proxyServer.sendMessage(finalMessage);
}else {
final Component FMessage = finalMessage;
proxyServer.getAllServers().forEach(server -> {
if (!Objects.equals(p.getCurrentServer().map(ServerConnection::getServerInfo).orElse(null), server.getServerInfo())) {
server.sendMessage(FMessage);
}
});
}
}
}

View File

@ -0,0 +1,36 @@
package me.feusalamander.vmessage;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
import com.velocitypowered.api.proxy.Player;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
public final class SendCommand implements SimpleCommand {
private final VMessage main;
SendCommand(VMessage main) {
this.main = main;
}
@Override
public void execute(final Invocation invocation) {
if(!hasPermission(invocation)){
return;
}
final CommandSource source = invocation.source();
final String[] args = invocation.arguments();
if (args.length == 0) {
source.sendMessage(Component.text("Usage: /sendall *your message*", NamedTextColor.RED));
return;
}
final Player p = (Player) source;
final String s = args[0];
main.listeners.message(p, s);
}
@Override
public boolean hasPermission(final Invocation invocation) {
return invocation.source() instanceof Player;
}
}

View File

@ -10,7 +10,6 @@ import com.velocitypowered.api.plugin.Dependency;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
import net.kyori.adventure.text.Component;
import org.slf4j.Logger;
import java.nio.file.Path;
@ -18,23 +17,26 @@ import java.nio.file.Path;
@Plugin(
id = "vmessage",
name = "Vmessage",
version = "1.6.1",
version = "1.5.5Pre",
description = "A velocity plugin that creates a multi server chat for the network",
authors = {"FeuSalamander"},
dependencies = {
@Dependency(id = "luckperms", optional = true)
@Dependency(id = "luckperms", optional = true),
@Dependency(id = "papiproxybridge",optional = true)
}
)
public class VMessage {
private final ProxyServer proxy;
private final Logger logger;
private final Metrics.Factory metricsFactory;
private final Path dataDirectory;
public Listeners listeners;
@Inject
public VMessage(ProxyServer proxy, Logger logger, @DataDirectory Path dataDirectory) {
public VMessage(ProxyServer proxy, Logger logger, Metrics.Factory metricsFactory, @DataDirectory Path dataDirectory) {
this.proxy = proxy;
this.logger = logger;
this.metricsFactory = metricsFactory;
this.dataDirectory = dataDirectory;
}
@ -44,14 +46,20 @@ public class VMessage {
if (configuration == null) {
return;
}
metricsFactory.make(this, 16527);
listeners = new Listeners(proxy, configuration);
proxy.getEventManager().register(this, listeners);
logger.info("Vmessage by FeuSalamander is working !");
CommandManager commandManager = proxy.getCommandManager();
CommandMeta commandMeta = commandManager.metaBuilder("Vmessage")
.plugin(this)
.build();
SimpleCommand command = new ReloadCommand(configuration);
commandManager.register(commandMeta, command);
logger.info("Vmessage by FeuSalamander is working !");
CommandMeta sendmeta = commandManager.metaBuilder("sendall")
.plugin(this)
.build();
SimpleCommand sendcommand = new SendCommand(this);
commandManager.register(sendmeta, sendcommand);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

View File

@ -2,14 +2,23 @@
[Message-format]
#set it to true to use MiniMessage and false to use hex colors
minimessage = false
[Message]
#place holders:
#- "#player#" : return the player name
#- "#prefix#" : return the player's luckperms prefix
#- "#suffix#" : return the player's luckperms suffix
#- "#message#" : return the player's message
#- "#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:
#- "#player#" : return the player name
#- "#server#" : return the new player's server name
#- "#prefix#" : return the player's luckperms prefix
#- "#suffix#" : return the player's luckperms suffix
#- "#custom1#" : return the player's custom defined luckperms meta keys
#- "#custom2#" : return the player's custom defined luckperms meta keys
format = "&7#prefix# #player# &ejoined &7#server#"
commands = [] #The proxy commands which are executed (no / in the commands)
enabled = true
@ -19,22 +28,9 @@ enabled = true
#- "#oldserver#" : return the previous player's server name
#- "#prefix#" : return the player's luckperms prefix
#- "#suffix#" : return the player's luckperms suffix
#- "#custom1#" : return the player's custom defined luckperms meta keys
#- "#custom2#" : return the player's custom defined luckperms meta keys
format = "#&7prefix# #player# &eleft &7#oldserver#"
commands = []
enabled = true
[Kick]
#place holders:
#- "#player#" : return the player name
#- "#oldserver#" : return the previous player's server name
#- "#prefix#" : return the player's luckperms prefix
#- "#suffix#" : return the player's luckperms suffix
#- "#custom1#" : return the player's custom defined luckperms meta keys
#- "#custom2#" : return the player's custom defined luckperms meta keys
format = "&7#prefix# #player# &ewas kicked from &7#oldserver#"
commands = [] #The proxy commands which are executed (no / in the commands)
enabled = true
[Server-change]
#place holders:
#- "#player#" : return the player name
@ -42,14 +38,6 @@ enabled = true
#- "#suffix#" : return the player's luckperms suffix
#- "#oldserver#" : return the previous player's server name
#- "#server#" : return the new player's server name
#- "#custom1#" : return the player's custom defined luckperms meta keys
#- "#custom2#" : return the player's custom defined luckperms meta keys
format = "&7#prefix# #player# &eleft &c#oldserver# &eto join &a#server#"
commands = []
enabled = true
[Aliases]
servername = "Server Name"
[Custom-Meta]
#Enables definition of Custom Luckperms Meta Placeholders
custom1 = ""
custom2 = ""

Binary file not shown.

After

Width:  |  Height:  |  Size: 656 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 927 KiB