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
@@ -94,7 +94,7 @@ public class VelocityPlayer implements AdaptedPlayer, Audience {
@Override
public void sendMessage(String message) {
handle.sendMessage(Component.text().content(message));
sendMessage(Component.text().content(message));
}
@Override
@@ -120,10 +120,23 @@ public class VelocityPlayer implements AdaptedPlayer, Audience {
handle.createConnectionRequest((RegisteredServer) server.getHandle()).connect().thenAcceptAsync(
result -> {
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,
server,
result.getReasonComponent().orElseGet(() -> Component.text("Connection failed")),
reason,
false
);
}