geforkt von Mirrors/Velocity
Rename connection field in ConnectedPlayer.
This sounds stupid, but YourKit really casts its net wide when it tries to instrument usages of JDBC. Velocity doesn't use JDBC, and yet if you run Velocity with YourKit (even without profiling active) you pay a significant cost.
Dieser Commit ist enthalten in:
Ursprung
d8e7f87506
Commit
5dbe6aa808
@ -422,7 +422,7 @@ public class VelocityServer implements ProxyServer {
|
||||
Preconditions.checkNotNull(component, "component");
|
||||
Chat chat = Chat.createClientbound(component);
|
||||
for (ConnectedPlayer player : connectionsByUuid.values()) {
|
||||
player.getConnection().write(chat);
|
||||
player.getMinecraftConnection().write(chat);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,8 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
||||
this.server = server;
|
||||
this.serverConn = serverConn;
|
||||
|
||||
MinecraftSessionHandler psh = serverConn.getPlayer().getConnection().getSessionHandler();
|
||||
MinecraftSessionHandler psh = serverConn.getPlayer().getMinecraftConnection()
|
||||
.getSessionHandler();
|
||||
if (!(psh instanceof ClientPlaySessionHandler)) {
|
||||
throw new IllegalStateException(
|
||||
"Initializing BackendPlaySessionHandler with no backing client play session handler!");
|
||||
@ -97,7 +98,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
||||
if (PluginMessageUtil.isMcBrand(packet)) {
|
||||
PluginMessage rewritten = PluginMessageUtil.rewriteMinecraftBrand(packet,
|
||||
server.getVersion());
|
||||
serverConn.getPlayer().getConnection().write(rewritten);
|
||||
serverConn.getPlayer().getMinecraftConnection().write(rewritten);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -111,7 +112,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
MinecraftConnection clientConn = serverConn.getPlayer().getConnection();
|
||||
MinecraftConnection clientConn = serverConn.getPlayer().getMinecraftConnection();
|
||||
PluginMessageEvent event = new PluginMessageEvent(serverConn, serverConn.getPlayer(), id,
|
||||
packet.getData());
|
||||
server.getEventManager().fire(event)
|
||||
@ -156,12 +157,12 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
||||
|
||||
@Override
|
||||
public void handleGeneric(MinecraftPacket packet) {
|
||||
serverConn.getPlayer().getConnection().write(packet);
|
||||
serverConn.getPlayer().getMinecraftConnection().write(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUnknown(ByteBuf buf) {
|
||||
serverConn.getPlayer().getConnection().write(buf.retain());
|
||||
serverConn.getPlayer().getMinecraftConnection().write(buf.retain());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -114,7 +114,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
VelocityServerConnection existingConnection = serverConn.getPlayer().getConnectedServer();
|
||||
if (existingConnection == null) {
|
||||
// Strap on the play session handler
|
||||
serverConn.getPlayer().getConnection()
|
||||
serverConn.getPlayer().getMinecraftConnection()
|
||||
.setSessionHandler(new ClientPlaySessionHandler(server, serverConn.getPlayer()));
|
||||
} else {
|
||||
// For Legacy Forge
|
||||
|
@ -10,7 +10,6 @@ import static com.velocitypowered.proxy.network.Connections.MINECRAFT_ENCODER;
|
||||
import static com.velocitypowered.proxy.network.Connections.READ_TIMEOUT;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.VerifyException;
|
||||
import com.velocitypowered.api.network.ProtocolVersion;
|
||||
import com.velocitypowered.api.proxy.ConnectionRequestBuilder;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
@ -22,7 +21,6 @@ import com.velocitypowered.proxy.connection.ConnectionTypes;
|
||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||
import com.velocitypowered.proxy.connection.MinecraftConnectionAssociation;
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
||||
@ -139,13 +137,13 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
||||
PlayerInfoForwarding forwardingMode = server.getConfiguration().getPlayerInfoForwardingMode();
|
||||
|
||||
// Initiate the handshake.
|
||||
ProtocolVersion protocolVersion = proxyPlayer.getConnection().getNextProtocolVersion();
|
||||
ProtocolVersion protocolVersion = proxyPlayer.getMinecraftConnection().getNextProtocolVersion();
|
||||
Handshake handshake = new Handshake();
|
||||
handshake.setNextStatus(StateRegistry.LOGIN_ID);
|
||||
handshake.setProtocolVersion(protocolVersion);
|
||||
if (forwardingMode == PlayerInfoForwarding.LEGACY) {
|
||||
handshake.setServerAddress(createLegacyForwardingAddress());
|
||||
} else if (proxyPlayer.getConnection().getType() == ConnectionTypes.LEGACY_FORGE) {
|
||||
} else if (proxyPlayer.getMinecraftConnection().getType() == ConnectionTypes.LEGACY_FORGE) {
|
||||
handshake.setServerAddress(handshake.getServerAddress() + HANDSHAKE_HOSTNAME_TOKEN);
|
||||
} else {
|
||||
handshake.setServerAddress(registeredServer.getServerInfo().getAddress().getHostString());
|
||||
|
@ -68,7 +68,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
public void activated() {
|
||||
PluginMessage register = PluginMessageUtil.constructChannelsPacket(player.getProtocolVersion(),
|
||||
server.getChannelRegistrar().getChannelsForProtocol(player.getProtocolVersion()));
|
||||
player.getConnection().write(register);
|
||||
player.getMinecraftConnection().write(register);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -165,7 +165,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
resp.setLength(longestLength);
|
||||
resp.getOffers().addAll(offers);
|
||||
|
||||
player.getConnection().write(resp);
|
||||
player.getMinecraftConnection().write(resp);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -288,7 +288,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
public void writabilityChanged() {
|
||||
VelocityServerConnection serverConn = player.getConnectedServer();
|
||||
if (serverConn != null) {
|
||||
boolean writable = player.getConnection().getChannel().isWritable();
|
||||
boolean writable = player.getMinecraftConnection().getChannel().isWritable();
|
||||
MinecraftConnection smc = serverConn.getConnection();
|
||||
if (smc != null) {
|
||||
smc.getChannel().config().setAutoRead(writable);
|
||||
@ -316,7 +316,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
if (!spawned) {
|
||||
// Nothing special to do with regards to spawning the player
|
||||
spawned = true;
|
||||
player.getConnection().delayedWrite(joinGame);
|
||||
player.getMinecraftConnection().delayedWrite(joinGame);
|
||||
|
||||
// Required for Legacy Forge
|
||||
player.getPhase().onFirstJoin(player);
|
||||
@ -336,12 +336,12 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
// Most notably, by having the client accept the join game packet, we can work around the need
|
||||
// to perform entity ID rewrites, eliminating potential issues from rewriting packets and
|
||||
// improving compatibility with mods.
|
||||
player.getConnection().delayedWrite(joinGame);
|
||||
player.getMinecraftConnection().delayedWrite(joinGame);
|
||||
int tempDim = joinGame.getDimension() == 0 ? -1 : 0;
|
||||
player.getConnection().delayedWrite(
|
||||
player.getMinecraftConnection().delayedWrite(
|
||||
new Respawn(tempDim, joinGame.getDifficulty(), joinGame.getGamemode(),
|
||||
joinGame.getLevelType()));
|
||||
player.getConnection().delayedWrite(
|
||||
player.getMinecraftConnection().delayedWrite(
|
||||
new Respawn(joinGame.getDimension(), joinGame.getDifficulty(), joinGame.getGamemode(),
|
||||
joinGame.getLevelType()));
|
||||
}
|
||||
@ -352,7 +352,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
BossBar deletePacket = new BossBar();
|
||||
deletePacket.setUuid(serverBossBar);
|
||||
deletePacket.setAction(BossBar.REMOVE);
|
||||
player.getConnection().delayedWrite(deletePacket);
|
||||
player.getMinecraftConnection().delayedWrite(deletePacket);
|
||||
}
|
||||
serverBossBars.clear();
|
||||
|
||||
@ -375,11 +375,11 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
|
||||
// Clear any title from the previous server.
|
||||
player.getConnection()
|
||||
player.getMinecraftConnection()
|
||||
.delayedWrite(TitlePacket.resetForProtocolVersion(player.getProtocolVersion()));
|
||||
|
||||
// Flush everything
|
||||
player.getConnection().flush();
|
||||
player.getMinecraftConnection().flush();
|
||||
serverMc.flush();
|
||||
serverConn.completeJoin();
|
||||
}
|
||||
@ -417,7 +417,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
player.getConnection().write(response);
|
||||
player.getMinecraftConnection().write(response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,7 +70,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(ConnectedPlayer.class);
|
||||
|
||||
private final MinecraftConnection connection;
|
||||
private final MinecraftConnection minecraftConnection;
|
||||
private final @Nullable InetSocketAddress virtualHost;
|
||||
private GameProfile profile;
|
||||
private PermissionFunction permissionFunction;
|
||||
@ -87,15 +87,15 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
@MonotonicNonNull
|
||||
private List<String> serversToTry = null;
|
||||
|
||||
ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection,
|
||||
@Nullable InetSocketAddress virtualHost) {
|
||||
ConnectedPlayer(VelocityServer server, GameProfile profile,
|
||||
MinecraftConnection minecraftConnection, @Nullable InetSocketAddress virtualHost) {
|
||||
this.server = server;
|
||||
this.tabList = new VelocityTabList(connection);
|
||||
this.tabList = new VelocityTabList(minecraftConnection);
|
||||
this.profile = profile;
|
||||
this.connection = connection;
|
||||
this.minecraftConnection = minecraftConnection;
|
||||
this.virtualHost = virtualHost;
|
||||
this.permissionFunction = PermissionFunction.ALWAYS_UNDEFINED;
|
||||
this.connectionPhase = connection.getType().getInitialClientPhase();
|
||||
this.connectionPhase = minecraftConnection.getType().getInitialClientPhase();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -117,8 +117,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public MinecraftConnection getConnection() {
|
||||
return connection;
|
||||
public MinecraftConnection getMinecraftConnection() {
|
||||
return minecraftConnection;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -151,7 +151,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getRemoteAddress() {
|
||||
return (InetSocketAddress) connection.getRemoteAddress();
|
||||
return (InetSocketAddress) minecraftConnection.getRemoteAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -165,12 +165,12 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return connection.getChannel().isActive();
|
||||
return minecraftConnection.getChannel().isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtocolVersion getProtocolVersion() {
|
||||
return connection.getProtocolVersion();
|
||||
return minecraftConnection.getProtocolVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -186,7 +186,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
TitlePacket pkt = new TitlePacket();
|
||||
pkt.setAction(TitlePacket.SET_ACTION_BAR);
|
||||
pkt.setComponent(ComponentSerializers.JSON.serialize(component));
|
||||
connection.write(pkt);
|
||||
minecraftConnection.write(pkt);
|
||||
return;
|
||||
} else {
|
||||
// Due to issues with action bar packets, we'll need to convert the text message into a
|
||||
@ -202,7 +202,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
Chat chat = new Chat();
|
||||
chat.setType(pos);
|
||||
chat.setMessage(json);
|
||||
connection.write(chat);
|
||||
minecraftConnection.write(chat);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -238,23 +238,23 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
@Override
|
||||
public void disconnect(Component reason) {
|
||||
logger.info("{} has disconnected: {}", this, ComponentSerializers.LEGACY.serialize(reason));
|
||||
connection.closeWith(Disconnect.create(reason));
|
||||
minecraftConnection.closeWith(Disconnect.create(reason));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(Title title) {
|
||||
Preconditions.checkNotNull(title, "title");
|
||||
|
||||
ProtocolVersion protocolVersion = minecraftConnection.getProtocolVersion();
|
||||
if (title.equals(Titles.reset())) {
|
||||
connection.write(TitlePacket.resetForProtocolVersion(connection.getProtocolVersion()));
|
||||
minecraftConnection.write(TitlePacket.resetForProtocolVersion(protocolVersion));
|
||||
} else if (title.equals(Titles.hide())) {
|
||||
connection.write(TitlePacket.hideForProtocolVersion(connection.getProtocolVersion()));
|
||||
minecraftConnection.write(TitlePacket.hideForProtocolVersion(protocolVersion));
|
||||
} else if (title instanceof TextTitle) {
|
||||
TextTitle tt = (TextTitle) title;
|
||||
|
||||
if (tt.isResetBeforeSend()) {
|
||||
connection
|
||||
.delayedWrite(TitlePacket.resetForProtocolVersion(connection.getProtocolVersion()));
|
||||
minecraftConnection.delayedWrite(TitlePacket.resetForProtocolVersion(protocolVersion));
|
||||
}
|
||||
|
||||
Optional<Component> titleText = tt.getTitle();
|
||||
@ -262,7 +262,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
TitlePacket titlePkt = new TitlePacket();
|
||||
titlePkt.setAction(TitlePacket.SET_TITLE);
|
||||
titlePkt.setComponent(ComponentSerializers.JSON.serialize(titleText.get()));
|
||||
connection.delayedWrite(titlePkt);
|
||||
minecraftConnection.delayedWrite(titlePkt);
|
||||
}
|
||||
|
||||
Optional<Component> subtitleText = tt.getSubtitle();
|
||||
@ -270,17 +270,17 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
TitlePacket titlePkt = new TitlePacket();
|
||||
titlePkt.setAction(TitlePacket.SET_SUBTITLE);
|
||||
titlePkt.setComponent(ComponentSerializers.JSON.serialize(subtitleText.get()));
|
||||
connection.delayedWrite(titlePkt);
|
||||
minecraftConnection.delayedWrite(titlePkt);
|
||||
}
|
||||
|
||||
if (tt.areTimesSet()) {
|
||||
TitlePacket timesPkt = TitlePacket.timesForProtocolVersion(connection.getProtocolVersion());
|
||||
TitlePacket timesPkt = TitlePacket.timesForProtocolVersion(protocolVersion);
|
||||
timesPkt.setFadeIn(tt.getFadeIn());
|
||||
timesPkt.setStay(tt.getStay());
|
||||
timesPkt.setFadeOut(tt.getFadeOut());
|
||||
connection.delayedWrite(timesPkt);
|
||||
minecraftConnection.delayedWrite(timesPkt);
|
||||
}
|
||||
connection.flush();
|
||||
minecraftConnection.flush();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown title class " + title.getClass().getName());
|
||||
}
|
||||
@ -388,7 +388,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
// In case someone gets creative, assume we want to disconnect the player.
|
||||
disconnect(friendlyReason);
|
||||
}
|
||||
}, connection.eventLoop());
|
||||
}, minecraftConnection.eventLoop());
|
||||
}
|
||||
}
|
||||
|
||||
@ -477,7 +477,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
PluginMessage message = new PluginMessage();
|
||||
message.setChannel(identifier.getId());
|
||||
message.setData(data);
|
||||
connection.write(message);
|
||||
minecraftConnection.write(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -496,7 +496,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
ResourcePackRequest request = new ResourcePackRequest();
|
||||
request.setUrl(url);
|
||||
request.setHash("");
|
||||
connection.write(request);
|
||||
minecraftConnection.write(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -508,7 +508,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
ResourcePackRequest request = new ResourcePackRequest();
|
||||
request.setUrl(url);
|
||||
request.setHash(ByteBufUtil.hexDump(hash));
|
||||
connection.write(request);
|
||||
minecraftConnection.write(request);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -517,10 +517,10 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
* ID last sent by the server.
|
||||
*/
|
||||
public void sendKeepAlive() {
|
||||
if (connection.getState() == StateRegistry.PLAY) {
|
||||
if (minecraftConnection.getState() == StateRegistry.PLAY) {
|
||||
KeepAlive keepAlive = new KeepAlive();
|
||||
keepAlive.setRandomId(ThreadLocalRandom.current().nextLong());
|
||||
connection.write(keepAlive);
|
||||
minecraftConnection.write(keepAlive);
|
||||
}
|
||||
}
|
||||
|
||||
@ -632,7 +632,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
// The only remaining value is successful (no need to do anything!)
|
||||
break;
|
||||
}
|
||||
}, connection.eventLoop())
|
||||
}, minecraftConnection.eventLoop())
|
||||
.thenApply(Result::isSuccessful);
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ public enum LegacyForgeHandshakeBackendPhase implements BackendConnectionPhase {
|
||||
serverConnection.setConnectionPhase(newPhase);
|
||||
|
||||
// Write the packet to the player, we don't need it now.
|
||||
player.getConnection().write(message);
|
||||
player.getMinecraftConnection().write(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ public enum LegacyForgeHandshakeClientPhase implements ClientConnectionPhase {
|
||||
COMPLETE(null) {
|
||||
@Override
|
||||
public void resetConnectionPhase(ConnectedPlayer player) {
|
||||
player.getConnection().write(LegacyForgeUtil.resetPacket());
|
||||
player.getMinecraftConnection().write(LegacyForgeUtil.resetPacket());
|
||||
player.setPhase(LegacyForgeHandshakeClientPhase.NOT_STARTED);
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren