forked from GeyserMC/Geyser
Fix AIOOBE and remove PlayerSession usage.
This commit is contained in:
parent
ab55050d11
commit
c9be13d487
3 changed files with 3 additions and 17 deletions
|
@ -109,6 +109,7 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
|
||||||
Player player = connector.getPlayers().get(bedrockServerSession.getAddress());
|
Player player = connector.getPlayers().get(bedrockServerSession.getAddress());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.disconnect(disconnectReason.name());
|
player.disconnect(disconnectReason.name());
|
||||||
|
connector.removePlayer(player);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
bedrockServerSession.setPacketCodec(GeyserConnector.BEDROCK_PACKET_CODEC);
|
bedrockServerSession.setPacketCodec(GeyserConnector.BEDROCK_PACKET_CODEC);
|
||||||
|
|
|
@ -38,8 +38,6 @@ import com.github.steveice10.packetlib.event.session.PacketReceivedEvent;
|
||||||
import com.github.steveice10.packetlib.event.session.SessionAdapter;
|
import com.github.steveice10.packetlib.event.session.SessionAdapter;
|
||||||
import com.github.steveice10.packetlib.packet.Packet;
|
import com.github.steveice10.packetlib.packet.Packet;
|
||||||
import com.github.steveice10.packetlib.tcp.TcpSessionFactory;
|
import com.github.steveice10.packetlib.tcp.TcpSessionFactory;
|
||||||
import com.nukkitx.network.util.DisconnectReason;
|
|
||||||
import com.nukkitx.protocol.PlayerSession;
|
|
||||||
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
||||||
import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
|
import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
|
||||||
import com.nukkitx.protocol.bedrock.data.GameRule;
|
import com.nukkitx.protocol.bedrock.data.GameRule;
|
||||||
|
@ -64,7 +62,7 @@ import java.net.InetSocketAddress;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class GeyserSession implements PlayerSession, Player {
|
public class GeyserSession implements Player {
|
||||||
|
|
||||||
private final GeyserConnector connector;
|
private final GeyserConnector connector;
|
||||||
private final BedrockServerSession upstream;
|
private final BedrockServerSession upstream;
|
||||||
|
@ -188,27 +186,14 @@ public class GeyserSession implements PlayerSession, Player {
|
||||||
closed = true;
|
closed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isClosed() {
|
public boolean isClosed() {
|
||||||
return closed;
|
return closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
public void close() {
|
||||||
disconnect("Server closed.");
|
disconnect("Server closed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisconnect(DisconnectReason disconnectReason) {
|
|
||||||
downstream.getSession().disconnect("Disconnected from server. Reason: " + disconnectReason);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisconnect(String reason) {
|
|
||||||
downstream.getSession().disconnect("Disconnected from server. Reason: " + reason);
|
|
||||||
connector.removePlayer(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthenticationData(AuthData authData) {
|
public void setAuthenticationData(AuthData authData) {
|
||||||
authenticationData = authData;
|
authenticationData = authData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
|
||||||
ChunkSection[] sections = chunkData.sections;
|
ChunkSection[] sections = chunkData.sections;
|
||||||
|
|
||||||
int sectionCount = sections.length - 1;
|
int sectionCount = sections.length - 1;
|
||||||
while (sections[sectionCount].isEmpty()) {
|
while (sectionCount >= 0 && sections[sectionCount].isEmpty()) {
|
||||||
sectionCount--;
|
sectionCount--;
|
||||||
}
|
}
|
||||||
sectionCount++;
|
sectionCount++;
|
||||||
|
|
Loading…
Reference in a new issue