option to send kick message on velocity

This commit is contained in:
ajgeiss0702
2021-09-03 17:58:50 -07:00
parent f29c9502c5
commit e946a0dba6
3 changed files with 25 additions and 5 deletions
@@ -225,6 +225,8 @@ public class QueueMain extends AjQueueAPI {
d.put("max-tries-reached", "&cUnable to connect to {SERVER}. Max retries reached."); d.put("max-tries-reached", "&cUnable to connect to {SERVER}. Max retries reached.");
d.put("auto-queued", "&aYou've been auto-queued for {SERVER} because you were kicked."); d.put("auto-queued", "&aYou've been auto-queued for {SERVER} because you were kicked.");
d.put("velocity-kick-message", "<red>You were kicked while trying to join {SERVER}: <white>{REASON}");
messages = new Messages(dataFolder, new LogConverter(logger), d); messages = new Messages(dataFolder, new LogConverter(logger), d);
} }
} }
+7 -2
View File
@@ -1,5 +1,5 @@
# Dont touch this number please # Dont touch this number please
config-version: 26 config-version: 27
# This is the main config for ajQueue. # This is the main config for ajQueue.
@@ -252,4 +252,9 @@ protocol-names:
- "108:1.9.1" - "108:1.9.1"
- "107:1.9" - "107:1.9"
- "47:1.8.9" - "47:1.8.9"
- "5:1.7.10" - "5:1.7.10"
# On velocity, should we end a player a message when they are kicked while trying to connect to a server with the queue?
# This has no effect on bungee, because the message is sent from bungee and theres no way to change that in ajQueue
# Default: false
velocity-kick-message: false
@@ -94,7 +94,7 @@ public class VelocityPlayer implements AdaptedPlayer, Audience {
@Override @Override
public void sendMessage(String message) { public void sendMessage(String message) {
handle.sendMessage(Component.text().content(message)); sendMessage(Component.text().content(message));
} }
@Override @Override
@@ -120,10 +120,23 @@ public class VelocityPlayer implements AdaptedPlayer, Audience {
handle.createConnectionRequest((RegisteredServer) server.getHandle()).connect().thenAcceptAsync( handle.createConnectionRequest((RegisteredServer) server.getHandle()).connect().thenAcceptAsync(
result -> { result -> {
if(!result.isSuccessful()) { if(!result.isSuccessful()) {
QueueMain.getInstance().getEventHandler().onServerKick( QueueMain main = QueueMain.getInstance();
Component reason = result.getReasonComponent().orElseGet(
() -> Component.text("Connection failed")
);
if(main.getConfig().getBoolean("velocity-kick-message")) {
handle.sendMessage(
main.getMessages().getComponent(
"velocity-kick-message",
"SERVER:"+server.getName(),
"REASON:"+reason
)
);
}
main.getEventHandler().onServerKick(
this, this,
server, server,
result.getReasonComponent().orElseGet(() -> Component.text("Connection failed")), reason,
false false
); );
} }