Compare commits

...

10 Commits

Author SHA1 Message Date
Evert Prants b06c38a271
Fork changes 2024-04-14 09:54:38 +03:00
FeuSalamander 6da6b227b6
Merge pull request #19 from ydal251/main 2024-01-06 22:14:41 +01:00
jones6096 bbd02becf1 Reimplement VelocityDiscord 2024-01-06 14:14:16 -05:00
jones6096 dd2057d905 Add KickedFromServerEvent
Temporarily removed VelocityDiscord Integration
2024-01-06 14:13:43 -05:00
FeuSalamander 983a64dafb updated README.md 2023-11-25 18:44:16 +01:00
FeuSalamander d6645fddd2 added discord integration 2023-11-25 18:32:59 +01:00
FeuSalamander 6cb80c86d1
Merge pull request #17 from ydal251/main 2023-11-24 12:12:04 +01:00
jones6096 0143d3fa0d Remove Unnecessary Check
Meta placeholders are always enabled, errors aren't thrown when an invalid or no meta key is requested
2023-11-23 22:04:12 -05:00
jones6096 b366dee1c1 Add Extra LP Meta Placeholders 2023-11-22 21:51:24 -05:00
FeuSalamander fbb1d57d54 added silent permission, added server aliases 2023-08-20 09:31:55 +02:00
10 changed files with 170 additions and 162 deletions

View File

@ -1,15 +1,14 @@
![](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**
# Vmessage fork
**Join/leave/change messages**
## Features
- **3 Events with custom messages for each**
- **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**
![](https://github.com/FeuSalamander/Vmessage/blob/main/src/main/resources/permissions.png?raw=true)
## Permissions
- **"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.6.1</version>
<packaging>jar</packaging>
<name>Vmessage</name>

View File

@ -10,41 +10,46 @@ 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);
messagecmd = config.getList("Message.commands");
aliases = config.getTable("Aliases");
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");
all = config.getBoolean("Message.all", false);
custom1 = config.getString("Custom-Meta.custom1", "");
custom2 = config.getString("Custom-Meta.custom2", "");
this.config = config;
}
@ -76,10 +81,6 @@ public final class Configuration {
}
}
public String getMessageFormat() {
return this.messageFormat;
}
public String getJoinFormat() {
return this.joinFormat;
}
@ -87,15 +88,14 @@ 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,6 +103,9 @@ public final class Configuration {
public boolean isLeaveEnabled() {
return this.leaveEnabled;
}
public boolean isKickEnabled() {
return this.kickEnabled;
}
public boolean isChangeEnabled() {
return this.changeEnabled;
@ -110,39 +113,50 @@ 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");
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.joincmd = config.getList("Join.commands");
this.leavecmd = config.getList("Leave.commands");
this.kickcmd = config.getList("Kick.commands");
this.changecmd = config.getList("Server-change.commands");
this.minimessage = config.getBoolean("Message-format.minimessage");
all = config.getBoolean("Message.all", false);
this.custom1 = config.getString("Custom-Meta.custom1");
this.custom2 = config.getString("Custom-Meta.custom2");
}
}

View File

@ -2,6 +2,7 @@ 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;
@ -15,6 +16,7 @@ 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;
@ -36,37 +38,33 @@ 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#", server.get().getServerInfo().getName());
.replace("#oldserver#", servername);
if (luckPermsAPI != null) {
s = luckperms(s, p);
}
@ -75,7 +73,49 @@ 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);
}
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);
if (luckPermsAPI != null) {
message = luckperms(message, p);
}
@ -98,14 +138,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 +165,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 +179,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 +200,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);
}
@ -157,53 +215,22 @@ public final class Listeners {
final CachedMetaData data = luckPermsAPI.getPlayerAdapter(Player.class).getMetaData(p);
final String prefix = data.getPrefix();
final String suffix = data.getSuffix();
if (message.contains("#prefix#")&&prefix != null) {
final String custom1 = data.getMetaValue(configuration.getCustom1());
final String custom2 = data.getMetaValue(configuration.getCustom2());
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);
}
message = message.replace("#prefix#", "").replace("#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#","");
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

@ -1,36 +0,0 @@
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,6 +10,7 @@ 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;
@ -17,26 +18,23 @@ import java.nio.file.Path;
@Plugin(
id = "vmessage",
name = "Vmessage",
version = "1.5.5Pre",
version = "1.6.1",
description = "A velocity plugin that creates a multi server chat for the network",
authors = {"FeuSalamander"},
dependencies = {
@Dependency(id = "luckperms", optional = true),
@Dependency(id = "papiproxybridge",optional = true)
@Dependency(id = "luckperms", 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, Metrics.Factory metricsFactory, @DataDirectory Path dataDirectory) {
public VMessage(ProxyServer proxy, Logger logger, @DataDirectory Path dataDirectory) {
this.proxy = proxy;
this.logger = logger;
this.metricsFactory = metricsFactory;
this.dataDirectory = dataDirectory;
}
@ -46,20 +44,14 @@ 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);
CommandMeta sendmeta = commandManager.metaBuilder("sendall")
.plugin(this)
.build();
SimpleCommand sendcommand = new SendCommand(this);
commandManager.register(sendmeta, sendcommand);
logger.info("Vmessage by FeuSalamander is working !");
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

View File

@ -2,23 +2,14 @@
[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
@ -28,9 +19,22 @@ 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
@ -38,6 +42,14 @@ 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.

Before

Width:  |  Height:  |  Size: 656 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 927 KiB