geforkt von Mirrors/Velocity
Merge pull request #253 from OKTW-Network/custom-redirect-message
Allow set redirect message
Dieser Commit ist enthalten in:
Commit
8d4f8f0bfa
@ -147,10 +147,12 @@ public final class KickedFromServerEvent implements
|
|||||||
*/
|
*/
|
||||||
public static final class RedirectPlayer implements ServerKickResult {
|
public static final class RedirectPlayer implements ServerKickResult {
|
||||||
|
|
||||||
|
private final Component message;
|
||||||
private final RegisteredServer server;
|
private final RegisteredServer server;
|
||||||
|
|
||||||
private RedirectPlayer(RegisteredServer server) {
|
private RedirectPlayer(RegisteredServer server, @Nullable Component message) {
|
||||||
this.server = Preconditions.checkNotNull(server, "server");
|
this.server = Preconditions.checkNotNull(server, "server");
|
||||||
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -162,14 +164,23 @@ public final class KickedFromServerEvent implements
|
|||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Component getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new redirect result to forward the player to the specified {@code server}.
|
* Creates a new redirect result to forward the player to the specified {@code server}.
|
||||||
*
|
*
|
||||||
* @param server the server to send the player to
|
* @param server the server to send the player to
|
||||||
* @return the redirect result
|
* @return the redirect result
|
||||||
*/
|
*/
|
||||||
public static RedirectPlayer create(RegisteredServer server) {
|
public static RedirectPlayer create(RegisteredServer server, @Nullable Component message) {
|
||||||
return new RedirectPlayer(server);
|
return new RedirectPlayer(server, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ServerKickResult create(RegisteredServer server) {
|
||||||
|
return create(server, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,7 +463,11 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
if (newResult == null || !newResult) {
|
if (newResult == null || !newResult) {
|
||||||
disconnect(friendlyReason);
|
disconnect(friendlyReason);
|
||||||
} else {
|
} else {
|
||||||
|
if (res.getMessage() == null) {
|
||||||
sendMessage(VelocityMessages.MOVED_TO_NEW_SERVER.append(friendlyReason));
|
sendMessage(VelocityMessages.MOVED_TO_NEW_SERVER.append(friendlyReason));
|
||||||
|
} else {
|
||||||
|
sendMessage(res.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, connection.eventLoop());
|
}, connection.eventLoop());
|
||||||
} else if (event.getResult() instanceof Notify) {
|
} else if (event.getResult() instanceof Notify) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren