Some more changes required by Geyser

This commit is contained in:
Camotoy 2022-10-20 18:33:28 -04:00
parent 3196b37922
commit e68553889b
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
4 changed files with 23 additions and 45 deletions

View file

@ -358,7 +358,7 @@ public class PacketHandler implements BedrockPacketHandler {
// Fetch the form and parse the response // Fetch the form and parse the response
Form window = player.getCurrentWindow(); Form window = player.getCurrentWindow();
FormResponse response = window.parseResponse(packet.getFormData().trim()); FormResponse response = window.parseResponse(packet.getFormData() == null ? null : packet.getFormData().trim());
// Resend the form if they closed it // Resend the form if they closed it
if (!response.isCorrect() && !id.isHandlesNull()) { if (!response.isCorrect() && !id.isHandlesNull()) {

View file

@ -50,7 +50,7 @@ import java.util.stream.Collectors;
public class GeyserProxyBootstrap implements GeyserBootstrap { public class GeyserProxyBootstrap implements GeyserBootstrap {
private GeyserProxyCommandManager geyserCommandManager; private GeyserCommandManager geyserCommandManager;
private GeyserProxyConfiguration geyserConfig; private GeyserProxyConfiguration geyserConfig;
private GeyserProxyLogger geyserLogger; private GeyserProxyLogger geyserLogger;
private IGeyserPingPassthrough geyserPingPassthrough; private IGeyserPingPassthrough geyserPingPassthrough;
@ -94,7 +94,7 @@ public class GeyserProxyBootstrap implements GeyserBootstrap {
// Create the connector and command manager // Create the connector and command manager
geyser = GeyserImpl.load(PlatformType.STANDALONE, this); geyser = GeyserImpl.load(PlatformType.STANDALONE, this);
GeyserImpl.start(); GeyserImpl.start();
geyserCommandManager = new GeyserProxyCommandManager(geyser); geyserCommandManager = new GeyserCommandManager(geyser);
// Start the ping passthrough thread, again don't think there is a point // Start the ping passthrough thread, again don't think there is a point
geyserPingPassthrough = GeyserLegacyPingPassthrough.init(geyser); geyserPingPassthrough = GeyserLegacyPingPassthrough.init(geyser);

View file

@ -1,41 +0,0 @@
/*
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/GeyserConnect
*/
package org.geysermc.connect.proxy;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.command.GeyserCommandManager;
public class GeyserProxyCommandManager extends GeyserCommandManager {
public GeyserProxyCommandManager(GeyserImpl geyser) {
super(geyser);
}
@Override
public String description(String command) {
return ""; // this is not sent over the protocol, so we return none
}
}

View file

@ -33,6 +33,8 @@ import com.nukkitx.nbt.NbtMap;
import com.nukkitx.protocol.bedrock.BedrockServerSession; import com.nukkitx.protocol.bedrock.BedrockServerSession;
import com.nukkitx.protocol.bedrock.data.*; import com.nukkitx.protocol.bedrock.data.*;
import com.nukkitx.protocol.bedrock.packet.*; import com.nukkitx.protocol.bedrock.packet.*;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import lombok.Getter; import lombok.Getter;
@ -58,6 +60,23 @@ import java.util.UUID;
@Getter @Getter
public class Player { public class Player {
private static final byte[] EMPTY_CHUNK_DATA;
static {
ByteBuf byteBuf = Unpooled.buffer();
try {
for (int i = 0; i < 32; i++) {
byteBuf.writeBytes(ChunkUtils.EMPTY_BIOME_DATA);
}
byteBuf.writeByte(0); // Border
EMPTY_CHUNK_DATA = new byte[byteBuf.readableBytes()];
byteBuf.readBytes(EMPTY_CHUNK_DATA);
} finally {
byteBuf.release();
}
}
private final AuthData authData; private final AuthData authData;
@Setter @Setter
@ -168,7 +187,7 @@ public class Player {
data.setChunkX(0); data.setChunkX(0);
data.setChunkZ(0); data.setChunkZ(0);
data.setSubChunksLength(0); data.setSubChunksLength(0);
data.setData(ChunkUtils.EMPTY_CHUNK_DATA); data.setData(EMPTY_CHUNK_DATA);
data.setCachingEnabled(false); data.setCachingEnabled(false);
session.sendPacket(data); session.sendPacket(data);