13
0
geforkt von Mirrors/Velocity

Fix Checkstyle issues

Dieser Commit ist enthalten in:
Andrew Steinborn 2019-11-26 16:32:50 -05:00
Ursprung 87ad188f92
Commit 0c14eabe6b
4 geänderte Dateien mit 28 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -53,7 +53,7 @@ class BungeeCordMessageResponder {
out.writeUTF("IP"); out.writeUTF("IP");
out.writeUTF(player.getRemoteAddress().getHostString()); out.writeUTF(player.getRemoteAddress().getHostString());
out.writeInt(player.getRemoteAddress().getPort()); out.writeInt(player.getRemoteAddress().getPort());
sendResponse(buf); sendResponseOnConnection(buf);
} }
private void processPlayerCount(ByteBufDataInput in) { private void processPlayerCount(ByteBufDataInput in) {
@ -75,7 +75,7 @@ class BungeeCordMessageResponder {
} }
if (buf.isReadable()) { if (buf.isReadable()) {
sendResponse(buf); sendResponseOnConnection(buf);
} else { } else {
buf.release(); buf.release();
} }
@ -109,7 +109,7 @@ class BungeeCordMessageResponder {
} }
if (buf.isReadable()) { if (buf.isReadable()) {
sendResponse(buf); sendResponseOnConnection(buf);
} else { } else {
buf.release(); buf.release();
} }
@ -126,7 +126,7 @@ class BungeeCordMessageResponder {
out.writeUTF("GetServers"); out.writeUTF("GetServers");
out.writeUTF(joiner.toString()); out.writeUTF(joiner.toString());
sendResponse(buf); sendResponseOnConnection(buf);
} }
private void processMessage(ByteBufDataInput in) { private void processMessage(ByteBufDataInput in) {
@ -150,7 +150,7 @@ class BungeeCordMessageResponder {
out.writeUTF("GetServer"); out.writeUTF("GetServer");
out.writeUTF(player.ensureAndGetCurrentServer().getServerInfo().getName()); out.writeUTF(player.ensureAndGetCurrentServer().getServerInfo().getName());
sendResponse(buf); sendResponseOnConnection(buf);
} }
private void processUuid() { private void processUuid() {
@ -160,7 +160,7 @@ class BungeeCordMessageResponder {
out.writeUTF("UUID"); out.writeUTF("UUID");
out.writeUTF(UuidUtils.toUndashed(player.getUniqueId())); out.writeUTF(UuidUtils.toUndashed(player.getUniqueId()));
sendResponse(buf); sendResponseOnConnection(buf);
} }
private void processUuidOther(ByteBufDataInput in) { private void processUuidOther(ByteBufDataInput in) {
@ -172,7 +172,7 @@ class BungeeCordMessageResponder {
out.writeUTF(player.getUsername()); out.writeUTF(player.getUsername());
out.writeUTF(UuidUtils.toUndashed(player.getUniqueId())); out.writeUTF(UuidUtils.toUndashed(player.getUniqueId()));
sendResponse(buf); sendResponseOnConnection(buf);
}); });
} }
@ -186,7 +186,7 @@ class BungeeCordMessageResponder {
out.writeUTF(info.getServerInfo().getAddress().getHostString()); out.writeUTF(info.getServerInfo().getAddress().getHostString());
out.writeShort(info.getServerInfo().getAddress().getPort()); out.writeShort(info.getServerInfo().getAddress().getPort());
sendResponse(buf); sendResponseOnConnection(buf);
}); });
} }
@ -212,7 +212,7 @@ class BungeeCordMessageResponder {
private void processForwardToPlayer(ByteBufDataInput in) { private void processForwardToPlayer(ByteBufDataInput in) {
proxy.getPlayer(in.readUTF()) proxy.getPlayer(in.readUTF())
.flatMap(Player::getCurrentServer) .flatMap(Player::getCurrentServer)
.ifPresent(server -> sendResponse(player, prepareForwardMessage(in))); .ifPresent(server -> sendServerResponse(player, prepareForwardMessage(in)));
} }
private void processForwardToServer(ByteBufDataInput in) { private void processForwardToServer(ByteBufDataInput in) {
@ -234,8 +234,8 @@ class BungeeCordMessageResponder {
} }
// Note: this method will always release the buffer! // Note: this method will always release the buffer!
private void sendResponse(ByteBuf buf) { private void sendResponseOnConnection(ByteBuf buf) {
sendResponse(this.player, buf); sendServerResponse(this.player, buf);
} }
static String getBungeeCordChannel(ProtocolVersion version) { static String getBungeeCordChannel(ProtocolVersion version) {
@ -244,7 +244,7 @@ class BungeeCordMessageResponder {
} }
// Note: this method will always release the buffer! // Note: this method will always release the buffer!
private static void sendResponse(ConnectedPlayer player, ByteBuf buf) { private static void sendServerResponse(ConnectedPlayer player, ByteBuf buf) {
MinecraftConnection serverConnection = player.ensureAndGetCurrentServer().ensureConnected(); MinecraftConnection serverConnection = player.ensureAndGetCurrentServer().ensureConnected();
String chan = getBungeeCordChannel(serverConnection.getProtocolVersion()); String chan = getBungeeCordChannel(serverConnection.getProtocolVersion());

Datei anzeigen

@ -214,6 +214,12 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
return sendPluginMessage(identifier, Unpooled.wrappedBuffer(data)); return sendPluginMessage(identifier, Unpooled.wrappedBuffer(data));
} }
/**
* Sends a plugin message to the server through this connection.
* @param identifier the channel ID to use
* @param data the data
* @return whether or not the message was sent
*/
public boolean sendPluginMessage(ChannelIdentifier identifier, ByteBuf data) { public boolean sendPluginMessage(ChannelIdentifier identifier, ByteBuf data) {
Preconditions.checkNotNull(identifier, "identifier"); Preconditions.checkNotNull(identifier, "identifier");
Preconditions.checkNotNull(data, "data"); Preconditions.checkNotNull(data, "data");

Datei anzeigen

@ -135,6 +135,10 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
return Optional.ofNullable(connectedServer); return Optional.ofNullable(connectedServer);
} }
/**
* Makes sure the player is connected to a server and returns the server they are connected to.
* @return the server the player is connected to
*/
public VelocityServerConnection ensureAndGetCurrentServer() { public VelocityServerConnection ensureAndGetCurrentServer() {
VelocityServerConnection con = this.connectedServer; VelocityServerConnection con = this.connectedServer;
if (con == null) { if (con == null) {

Datei anzeigen

@ -126,6 +126,12 @@ public class VelocityRegisteredServer implements RegisteredServer {
return sendPluginMessage(identifier, Unpooled.wrappedBuffer(data)); return sendPluginMessage(identifier, Unpooled.wrappedBuffer(data));
} }
/**
* Sends a plugin message to the server through this connection.
* @param identifier the channel ID to use
* @param data the data
* @return whether or not the message was sent
*/
public boolean sendPluginMessage(ChannelIdentifier identifier, ByteBuf data) { public boolean sendPluginMessage(ChannelIdentifier identifier, ByteBuf data) {
for (ConnectedPlayer player : players) { for (ConnectedPlayer player : players) {
VelocityServerConnection connection = player.getConnectedServer(); VelocityServerConnection connection = player.getConnectedServer();