3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-23 23:00:35 +01:00

Allow set redirect message

Dieser Commit ist enthalten in:
james58899 2019-10-14 22:00:07 +08:00
Ursprung 20559e059d
Commit bd35c6835e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7F83E3A11DD5192E
2 geänderte Dateien mit 19 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -147,10 +147,12 @@ public final class KickedFromServerEvent implements
*/
public static final class RedirectPlayer implements ServerKickResult {
private final Component message;
private final RegisteredServer server;
private RedirectPlayer(RegisteredServer server) {
private RedirectPlayer(RegisteredServer server, @Nullable Component message) {
this.server = Preconditions.checkNotNull(server, "server");
this.message = message;
}
@Override
@ -162,14 +164,23 @@ public final class KickedFromServerEvent implements
return server;
}
@Nullable
public Component getMessage() {
return message;
}
/**
* Creates a new redirect result to forward the player to the specified {@code server}.
*
* @param server the server to send the player to
* @return the redirect result
*/
public static RedirectPlayer create(RegisteredServer server) {
return new RedirectPlayer(server);
public static RedirectPlayer create(RegisteredServer server, @Nullable Component message) {
return new RedirectPlayer(server, message);
}
public static ServerKickResult create(RegisteredServer server) {
return create(server, null);
}
}

Datei anzeigen

@ -463,7 +463,11 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
if (newResult == null || !newResult) {
disconnect(friendlyReason);
} else {
sendMessage(VelocityMessages.MOVED_TO_NEW_SERVER.append(friendlyReason));
if (res.getMessage() == null) {
sendMessage(VelocityMessages.MOVED_TO_NEW_SERVER.append(friendlyReason));
} else {
sendMessage(res.getMessage());
}
}
}, connection.eventLoop());
} else if (event.getResult() instanceof Notify) {