Merge pull request #19 from ydal251/main
This commit is contained in:
commit
6da6b227b6
@ -13,10 +13,12 @@ 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;
|
||||
@ -25,6 +27,7 @@ public final class Configuration {
|
||||
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;
|
||||
@ -34,11 +37,13 @@ public final class Configuration {
|
||||
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");
|
||||
@ -46,6 +51,7 @@ public final class Configuration {
|
||||
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");
|
||||
all = config.getBoolean("Message.all", false);
|
||||
@ -94,6 +100,9 @@ public final class Configuration {
|
||||
public String getLeaveFormat() {
|
||||
return this.leaveFormat;
|
||||
}
|
||||
public String getKickFormat() {
|
||||
return this.kickFormat;
|
||||
}
|
||||
|
||||
public String getChangeFormat() {
|
||||
return this.changeFormat;
|
||||
@ -110,6 +119,9 @@ public final class Configuration {
|
||||
public boolean isLeaveEnabled() {
|
||||
return this.leaveEnabled;
|
||||
}
|
||||
public boolean isKickEnabled() {
|
||||
return this.kickEnabled;
|
||||
}
|
||||
|
||||
public boolean isChangeEnabled() {
|
||||
return this.changeEnabled;
|
||||
@ -129,6 +141,9 @@ public final class Configuration {
|
||||
public List<String> getLeavecmd(){
|
||||
return this.leavecmd;
|
||||
}
|
||||
public List<String> getKickcmd(){
|
||||
return this.kickcmd;
|
||||
}
|
||||
public List<String> getChangecmd(){
|
||||
return this.changecmd;
|
||||
}
|
||||
@ -147,11 +162,13 @@ public final class Configuration {
|
||||
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");
|
||||
@ -159,6 +176,7 @@ public final class Configuration {
|
||||
this.messagecmd = config.getList("Message.commands");
|
||||
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");
|
||||
|
@ -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;
|
||||
@ -107,6 +108,63 @@ public final class Listeners {
|
||||
if(VMessage.isDiscord())VelocityDiscord.getDiscord().sendMessage(discordRaw);
|
||||
}
|
||||
|
||||
}
|
||||
@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);
|
||||
}
|
||||
String discordRaw;
|
||||
if(VMessage.isDiscord()){
|
||||
String dump = "";
|
||||
String[] dump2 = message.replace("&", "§").split("§");
|
||||
proxyServer.sendMessage(Component.text(Arrays.toString(dump2)));
|
||||
for(String string : dump2){
|
||||
if(string.length() >1)
|
||||
dump = dump+string.substring(1);
|
||||
}
|
||||
discordRaw = dump;
|
||||
} else {
|
||||
discordRaw = message;
|
||||
}
|
||||
if (configuration.isMinimessageEnabled()) {
|
||||
proxyServer.sendMessage(mm.deserialize(message.replace("§", "")));
|
||||
if(VMessage.isDiscord())VelocityDiscord.getDiscord().sendMessage(discordRaw);
|
||||
} else {
|
||||
proxyServer.sendMessage(SERIALIZER.deserialize(message));
|
||||
if(VMessage.isDiscord())VelocityDiscord.getDiscord().sendMessage(discordRaw);
|
||||
}
|
||||
|
||||
}
|
||||
@Subscribe
|
||||
private void onChange(final ServerPostConnectEvent e) {
|
||||
|
@ -37,6 +37,17 @@ enabled = true
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user