Compare commits
10 Commits
68f4824593
...
b06c38a271
Author | SHA1 | Date | |
---|---|---|---|
b06c38a271 | |||
|
6da6b227b6 | ||
|
bbd02becf1 | ||
|
dd2057d905 | ||
|
983a64dafb | ||
|
d6645fddd2 | ||
|
6cb80c86d1 | ||
|
0143d3fa0d | ||
|
b366dee1c1 | ||
|
fbb1d57d54 |
15
README.md
15
README.md
@ -1,15 +1,14 @@
|
|||||||
![](https://github.com/FeuSalamander/Vmessage/blob/main/src/main/resources/Vmessage_desc.jpg?raw=true)
|
# Vmessage fork
|
||||||
**Ever wanted to have your messages sent globally across your Velocity proxy with LuckPerms ranks ? Here's a simple plugin to do just that!**
|
**Join/leave/change messages**
|
||||||
![](https://github.com/FeuSalamander/Vmessage/blob/main/src/main/resources/features.png?raw=true)
|
## Features
|
||||||
- **4 Events with custom messages for each**
|
- **3 Events with custom messages for each**
|
||||||
- **Player Message**
|
|
||||||
- **Player join the network**
|
- **Player join the network**
|
||||||
- **Player left the network**
|
- **Player left the network**
|
||||||
- **Player server change**
|
- **Player server change**
|
||||||
- **LuckPerms Prefix and Suffix Support**
|
- **LuckPerms Prefix and Suffix Support**
|
||||||
- **Reload command: "/vmessage reload"**
|
- **Reload command: "/vmessage reload"**
|
||||||
- **Global message command: "/sendall"**
|
|
||||||
- **MiniMessage support**
|
- **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.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**
|
||||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>Vmessage</groupId>
|
<groupId>Vmessage</groupId>
|
||||||
<artifactId>Vmessage</artifactId>
|
<artifactId>Vmessage</artifactId>
|
||||||
<version>1.5.5Pre</version>
|
<version>1.6.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Vmessage</name>
|
<name>Vmessage</name>
|
||||||
|
@ -10,41 +10,46 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public final class Configuration {
|
public final class Configuration {
|
||||||
private String messageFormat;
|
|
||||||
private String joinFormat;
|
private String joinFormat;
|
||||||
private String leaveFormat;
|
private String leaveFormat;
|
||||||
|
private String kickFormat;
|
||||||
private String changeFormat;
|
private String changeFormat;
|
||||||
private boolean messageEnabled;
|
|
||||||
private boolean joinEnabled;
|
private boolean joinEnabled;
|
||||||
private boolean leaveEnabled;
|
private boolean leaveEnabled;
|
||||||
|
private boolean kickEnabled;
|
||||||
private boolean changeEnabled;
|
private boolean changeEnabled;
|
||||||
private boolean minimessage;
|
private boolean minimessage;
|
||||||
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> joincmd;
|
||||||
private List<String> leavecmd;
|
private List<String> leavecmd;
|
||||||
|
private List<String> kickcmd;
|
||||||
private List<String> changecmd;
|
private List<String> changecmd;
|
||||||
|
private String custom1;
|
||||||
|
private String custom2;
|
||||||
|
private Toml aliases;
|
||||||
|
|
||||||
Configuration(Toml config) {
|
Configuration(Toml config) {
|
||||||
messageFormat = config.getString("Message.format", "");
|
|
||||||
joinFormat = config.getString("Join.format", "");
|
joinFormat = config.getString("Join.format", "");
|
||||||
leaveFormat = config.getString("Leave.format", "");
|
leaveFormat = config.getString("Leave.format", "");
|
||||||
|
kickFormat = config.getString("Kick.format", "");
|
||||||
changeFormat = config.getString("Server-change.format", "");
|
changeFormat = config.getString("Server-change.format", "");
|
||||||
|
|
||||||
messageEnabled = config.getBoolean("Message.enabled", false);
|
|
||||||
joinEnabled = config.getBoolean("Join.enabled", false);
|
joinEnabled = config.getBoolean("Join.enabled", false);
|
||||||
leaveEnabled = config.getBoolean("Leave.enabled", false);
|
leaveEnabled = config.getBoolean("Leave.enabled", false);
|
||||||
|
kickEnabled = config.getBoolean("Kick.enabled", false);
|
||||||
changeEnabled = config.getBoolean("Server-change.enabled", false);
|
changeEnabled = config.getBoolean("Server-change.enabled", false);
|
||||||
|
|
||||||
messagecmd = config.getList("Message.commands");
|
aliases = config.getTable("Aliases");
|
||||||
|
|
||||||
joincmd = config.getList("Join.commands");
|
joincmd = config.getList("Join.commands");
|
||||||
leavecmd = config.getList("Leave.commands");
|
leavecmd = config.getList("Leave.commands");
|
||||||
|
kickcmd = config.getList("Kick.commands");
|
||||||
changecmd = config.getList("Server-change.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);
|
|
||||||
|
custom1 = config.getString("Custom-Meta.custom1", "");
|
||||||
|
custom2 = config.getString("Custom-Meta.custom2", "");
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,10 +81,6 @@ public final class Configuration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessageFormat() {
|
|
||||||
return this.messageFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getJoinFormat() {
|
public String getJoinFormat() {
|
||||||
return this.joinFormat;
|
return this.joinFormat;
|
||||||
}
|
}
|
||||||
@ -87,15 +88,14 @@ public final class Configuration {
|
|||||||
public String getLeaveFormat() {
|
public String getLeaveFormat() {
|
||||||
return this.leaveFormat;
|
return this.leaveFormat;
|
||||||
}
|
}
|
||||||
|
public String getKickFormat() {
|
||||||
|
return this.kickFormat;
|
||||||
|
}
|
||||||
|
|
||||||
public String getChangeFormat() {
|
public String getChangeFormat() {
|
||||||
return this.changeFormat;
|
return this.changeFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMessageEnabled() {
|
|
||||||
return this.messageEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isJoinEnabled() {
|
public boolean isJoinEnabled() {
|
||||||
return this.joinEnabled;
|
return this.joinEnabled;
|
||||||
}
|
}
|
||||||
@ -103,6 +103,9 @@ public final class Configuration {
|
|||||||
public boolean isLeaveEnabled() {
|
public boolean isLeaveEnabled() {
|
||||||
return this.leaveEnabled;
|
return this.leaveEnabled;
|
||||||
}
|
}
|
||||||
|
public boolean isKickEnabled() {
|
||||||
|
return this.kickEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isChangeEnabled() {
|
public boolean isChangeEnabled() {
|
||||||
return this.changeEnabled;
|
return this.changeEnabled;
|
||||||
@ -110,39 +113,50 @@ public final class Configuration {
|
|||||||
public boolean isMinimessageEnabled(){
|
public boolean isMinimessageEnabled(){
|
||||||
return this.minimessage;
|
return this.minimessage;
|
||||||
}
|
}
|
||||||
public boolean isAllEnabled(){
|
|
||||||
return this.all;
|
|
||||||
}
|
|
||||||
public List<String> getMessagecmd(){
|
|
||||||
return this.messagecmd;
|
|
||||||
}
|
|
||||||
public List<String> getJoincmd(){
|
public List<String> getJoincmd(){
|
||||||
return this.joincmd;
|
return this.joincmd;
|
||||||
}
|
}
|
||||||
public List<String> getLeavecmd(){
|
public List<String> getLeavecmd(){
|
||||||
return this.leavecmd;
|
return this.leavecmd;
|
||||||
}
|
}
|
||||||
|
public List<String> getKickcmd(){
|
||||||
|
return this.kickcmd;
|
||||||
|
}
|
||||||
public List<String> getChangecmd(){
|
public List<String> getChangecmd(){
|
||||||
return this.changecmd;
|
return this.changecmd;
|
||||||
}
|
}
|
||||||
|
public Toml getAliases() {
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
|
public String getCustom1() {
|
||||||
|
return this.custom1;
|
||||||
|
}
|
||||||
|
public String getCustom2() {
|
||||||
|
return this.custom2;
|
||||||
|
}
|
||||||
|
|
||||||
void reload(){
|
void reload(){
|
||||||
config = config.read(file);
|
config = config.read(file);
|
||||||
this.messageFormat = config.getString("Message.format");
|
|
||||||
this.joinFormat = config.getString("Join.format");
|
this.joinFormat = config.getString("Join.format");
|
||||||
this.leaveFormat = config.getString("Leave.format");
|
this.leaveFormat = config.getString("Leave.format");
|
||||||
|
this.kickFormat = config.getString("Kick.format");
|
||||||
this.changeFormat = config.getString("Server-change.format");
|
this.changeFormat = config.getString("Server-change.format");
|
||||||
|
|
||||||
this.messageEnabled = config.getBoolean("Message.enabled");
|
|
||||||
this.joinEnabled = config.getBoolean("Join.enabled");
|
this.joinEnabled = config.getBoolean("Join.enabled");
|
||||||
this.leaveEnabled = config.getBoolean("Leave.enabled");
|
this.leaveEnabled = config.getBoolean("Leave.enabled");
|
||||||
|
this.kickEnabled = config.getBoolean("Kick.enabled");
|
||||||
this.changeEnabled = config.getBoolean("Server-change.enabled");
|
this.changeEnabled = config.getBoolean("Server-change.enabled");
|
||||||
|
|
||||||
messagecmd = config.getList("Message.commands");
|
this.aliases = config.getTable("Aliases");
|
||||||
joincmd = config.getList("Join.commands");
|
|
||||||
leavecmd = config.getList("Leave.commands");
|
this.joincmd = config.getList("Join.commands");
|
||||||
changecmd = config.getList("Server-change.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");
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package me.feusalamander.vmessage;
|
|||||||
|
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
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.PlayerChatEvent;
|
||||||
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
|
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
@ -15,6 +16,7 @@ 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 java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -36,37 +38,33 @@ public final class Listeners {
|
|||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
this.proxyServer = proxyServer;
|
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
|
@Subscribe
|
||||||
private void onLeave(final DisconnectEvent e) {
|
private void onLeave(final DisconnectEvent e) {
|
||||||
if (!configuration.isLeaveEnabled()) {
|
if (!configuration.isLeaveEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!e.getLoginStatus().equals(DisconnectEvent.LoginStatus.SUCCESSFUL_LOGIN)){
|
if (!e.getLoginStatus().equals(DisconnectEvent.LoginStatus.SUCCESSFUL_LOGIN)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(e.getPlayer().hasPermission("vmessage.silent.leave")){
|
||||||
|
return;
|
||||||
|
}
|
||||||
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();
|
||||||
|
String servername = server.get().getServerInfo().getName();
|
||||||
|
if(configuration.getAliases().contains(servername)){
|
||||||
|
servername = configuration.getAliases().getString(servername);
|
||||||
|
}
|
||||||
if(configuration.getLeavecmd() != null&&!configuration.getLeavecmd().isEmpty())
|
if(configuration.getLeavecmd() != null&&!configuration.getLeavecmd().isEmpty())
|
||||||
for(String s : configuration.getLeavecmd()){
|
for(String s : configuration.getLeavecmd()){
|
||||||
s = s
|
s = s
|
||||||
.replace("#player#", p.getUsername())
|
.replace("#player#", p.getUsername())
|
||||||
.replace("#oldserver#", server.get().getServerInfo().getName());
|
.replace("#oldserver#", servername);
|
||||||
if (luckPermsAPI != null) {
|
if (luckPermsAPI != null) {
|
||||||
s = luckperms(s, p);
|
s = luckperms(s, p);
|
||||||
}
|
}
|
||||||
@ -75,7 +73,49 @@ public final class Listeners {
|
|||||||
if(message.isEmpty())return;
|
if(message.isEmpty())return;
|
||||||
message = message
|
message = message
|
||||||
.replace("#player#", p.getUsername())
|
.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) {
|
if (luckPermsAPI != null) {
|
||||||
message = luckperms(message, p);
|
message = luckperms(message, p);
|
||||||
}
|
}
|
||||||
@ -98,14 +138,25 @@ public final class Listeners {
|
|||||||
if (!configuration.isChangeEnabled()) {
|
if (!configuration.isChangeEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(e.getPlayer().hasPermission("vmessage.silent.change")){
|
||||||
|
return;
|
||||||
|
}
|
||||||
final ServerConnection actual = serverConnection.get();
|
final ServerConnection actual = serverConnection.get();
|
||||||
String message = configuration.getChangeFormat();
|
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())
|
if(configuration.getChangecmd() != null&&!configuration.getChangecmd().isEmpty())
|
||||||
for(String s : configuration.getChangecmd()){
|
for(String s : configuration.getChangecmd()){
|
||||||
s = s
|
s = s
|
||||||
.replace("#player#", p.getUsername())
|
.replace("#player#", p.getUsername())
|
||||||
.replace("#oldserver#", pre.getServerInfo().getName())
|
.replace("#oldserver#", oldservername)
|
||||||
.replace("#server#", actual.getServerInfo().getName());
|
.replace("#server#", actualservername);
|
||||||
if (luckPermsAPI != null) {
|
if (luckPermsAPI != null) {
|
||||||
s = luckperms(s, p);
|
s = luckperms(s, p);
|
||||||
}
|
}
|
||||||
@ -114,8 +165,8 @@ public final class Listeners {
|
|||||||
if(message.isEmpty())return;
|
if(message.isEmpty())return;
|
||||||
message = message
|
message = message
|
||||||
.replace("#player#", p.getUsername())
|
.replace("#player#", p.getUsername())
|
||||||
.replace("#oldserver#", pre.getServerInfo().getName())
|
.replace("#oldserver#", oldservername)
|
||||||
.replace("#server#", actual.getServerInfo().getName());
|
.replace("#server#", actualservername);
|
||||||
if (luckPermsAPI != null) {
|
if (luckPermsAPI != null) {
|
||||||
message = luckperms(message, p);
|
message = luckperms(message, p);
|
||||||
}
|
}
|
||||||
@ -128,11 +179,18 @@ public final class Listeners {
|
|||||||
if (!configuration.isJoinEnabled()) {
|
if (!configuration.isJoinEnabled()) {
|
||||||
return;
|
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())
|
if(configuration.getJoincmd() != null&&!configuration.getJoincmd().isEmpty())
|
||||||
for(String s : configuration.getJoincmd()){
|
for(String s : configuration.getJoincmd()){
|
||||||
s = s
|
s = s
|
||||||
.replace("#player#", p.getUsername())
|
.replace("#player#", p.getUsername())
|
||||||
.replace("#server#", serverConnection.get().getServerInfo().getName());
|
.replace("#server#", actualservername);
|
||||||
if (luckPermsAPI != null) {
|
if (luckPermsAPI != null) {
|
||||||
s = luckperms(s, p);
|
s = luckperms(s, p);
|
||||||
}
|
}
|
||||||
@ -142,7 +200,7 @@ public final class Listeners {
|
|||||||
if(message.isEmpty())return;
|
if(message.isEmpty())return;
|
||||||
message = message
|
message = message
|
||||||
.replace("#player#", p.getUsername())
|
.replace("#player#", p.getUsername())
|
||||||
.replace("#server#", serverConnection.get().getServerInfo().getName());
|
.replace("#server#", actualservername);
|
||||||
if (luckPermsAPI != null) {
|
if (luckPermsAPI != null) {
|
||||||
message = luckperms(message, p);
|
message = luckperms(message, p);
|
||||||
}
|
}
|
||||||
@ -157,53 +215,22 @@ public final class Listeners {
|
|||||||
final CachedMetaData data = luckPermsAPI.getPlayerAdapter(Player.class).getMetaData(p);
|
final CachedMetaData data = luckPermsAPI.getPlayerAdapter(Player.class).getMetaData(p);
|
||||||
final String prefix = data.getPrefix();
|
final String prefix = data.getPrefix();
|
||||||
final String suffix = data.getSuffix();
|
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);
|
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("#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;
|
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,6 +10,7 @@ import com.velocitypowered.api.plugin.Dependency;
|
|||||||
import com.velocitypowered.api.plugin.Plugin;
|
import com.velocitypowered.api.plugin.Plugin;
|
||||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@ -17,26 +18,23 @@ import java.nio.file.Path;
|
|||||||
@Plugin(
|
@Plugin(
|
||||||
id = "vmessage",
|
id = "vmessage",
|
||||||
name = "Vmessage",
|
name = "Vmessage",
|
||||||
version = "1.5.5Pre",
|
version = "1.6.1",
|
||||||
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 = {
|
||||||
@Dependency(id = "luckperms", optional = true),
|
@Dependency(id = "luckperms", optional = true)
|
||||||
@Dependency(id = "papiproxybridge",optional = true)
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
public class VMessage {
|
public class VMessage {
|
||||||
private final ProxyServer proxy;
|
private final ProxyServer proxy;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
private final Metrics.Factory metricsFactory;
|
|
||||||
private final Path dataDirectory;
|
private final Path dataDirectory;
|
||||||
public Listeners listeners;
|
public Listeners listeners;
|
||||||
|
|
||||||
@Inject
|
@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.proxy = proxy;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.metricsFactory = metricsFactory;
|
|
||||||
this.dataDirectory = dataDirectory;
|
this.dataDirectory = dataDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,20 +44,14 @@ public class VMessage {
|
|||||||
if (configuration == null) {
|
if (configuration == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
metricsFactory.make(this, 16527);
|
|
||||||
listeners = new Listeners(proxy, configuration);
|
listeners = new Listeners(proxy, configuration);
|
||||||
proxy.getEventManager().register(this, listeners);
|
proxy.getEventManager().register(this, listeners);
|
||||||
logger.info("Vmessage by FeuSalamander is working !");
|
|
||||||
CommandManager commandManager = proxy.getCommandManager();
|
CommandManager commandManager = proxy.getCommandManager();
|
||||||
CommandMeta commandMeta = commandManager.metaBuilder("Vmessage")
|
CommandMeta commandMeta = commandManager.metaBuilder("Vmessage")
|
||||||
.plugin(this)
|
.plugin(this)
|
||||||
.build();
|
.build();
|
||||||
SimpleCommand command = new ReloadCommand(configuration);
|
SimpleCommand command = new ReloadCommand(configuration);
|
||||||
commandManager.register(commandMeta, command);
|
commandManager.register(commandMeta, command);
|
||||||
CommandMeta sendmeta = commandManager.metaBuilder("sendall")
|
logger.info("Vmessage by FeuSalamander is working !");
|
||||||
.plugin(this)
|
|
||||||
.build();
|
|
||||||
SimpleCommand sendcommand = new SendCommand(this);
|
|
||||||
commandManager.register(sendmeta, sendcommand);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.7 MiB |
@ -2,23 +2,14 @@
|
|||||||
[Message-format]
|
[Message-format]
|
||||||
#set it to true to use MiniMessage and false to use hex colors
|
#set it to true to use MiniMessage and false to use hex colors
|
||||||
minimessage = false
|
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]
|
[Join]
|
||||||
#place holders:
|
#place holders:
|
||||||
#- "#player#" : return the player name
|
#- "#player#" : return the player name
|
||||||
#- "#server#" : return the new player's server name
|
#- "#server#" : return the new player's server name
|
||||||
#- "#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
|
||||||
|
#- "#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#"
|
format = "&7#prefix# #player# &ejoined &7#server#"
|
||||||
commands = [] #The proxy commands which are executed (no / in the commands)
|
commands = [] #The proxy commands which are executed (no / in the commands)
|
||||||
enabled = true
|
enabled = true
|
||||||
@ -28,9 +19,22 @@ enabled = true
|
|||||||
#- "#oldserver#" : return the previous player's server name
|
#- "#oldserver#" : return the previous player's server name
|
||||||
#- "#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
|
||||||
|
#- "#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#"
|
format = "#&7prefix# #player# &eleft &7#oldserver#"
|
||||||
commands = []
|
commands = []
|
||||||
enabled = true
|
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]
|
[Server-change]
|
||||||
#place holders:
|
#place holders:
|
||||||
#- "#player#" : return the player name
|
#- "#player#" : return the player name
|
||||||
@ -38,6 +42,14 @@ enabled = true
|
|||||||
#- "#suffix#" : return the player's luckperms suffix
|
#- "#suffix#" : return the player's luckperms suffix
|
||||||
#- "#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
|
||||||
|
#- "#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#"
|
format = "&7#prefix# #player# &eleft &c#oldserver# &eto join &a#server#"
|
||||||
commands = []
|
commands = []
|
||||||
enabled = true
|
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 |
Loading…
Reference in New Issue
Block a user