forked from GeyserMC/Geyser
Code cleanups
This commit is contained in:
parent
d0347c537d
commit
82f56a7c34
6 changed files with 8 additions and 44 deletions
|
@ -29,7 +29,6 @@ import com.nukkitx.protocol.bedrock.BedrockPong;
|
|||
import com.nukkitx.protocol.bedrock.BedrockServerEventHandler;
|
||||
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
||||
import com.nukkitx.protocol.bedrock.v361.Bedrock_v361;
|
||||
import org.geysermc.api.Geyser;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.configuration.GeyserConfiguration;
|
||||
import org.geysermc.connector.console.GeyserLogger;
|
||||
|
@ -77,7 +76,4 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
|
|||
bedrockServerSession.addDisconnectHandler((x) -> GeyserLogger.DEFAULT.warning("Bedrock user with ip: " + bedrockServerSession.getAddress().getAddress() + " has disconnected for reason " + x));
|
||||
bedrockServerSession.setPacketCodec(Bedrock_v361.V361_CODEC);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -29,7 +29,6 @@ import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerSwingArmPacket;
|
||||
import com.nimbusds.jose.JWSObject;
|
||||
import com.nukkitx.protocol.bedrock.handler.BatchHandler;
|
||||
import com.nukkitx.protocol.bedrock.handler.BedrockPacketHandler;
|
||||
import com.nukkitx.protocol.bedrock.packet.*;
|
||||
import net.minidev.json.JSONArray;
|
||||
|
|
|
@ -26,16 +26,15 @@
|
|||
package org.geysermc.connector.network.translators;
|
||||
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import org.geysermc.api.Geyser;
|
||||
import org.geysermc.connector.console.GeyserLogger;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Registry<T> {
|
||||
|
||||
private final Map<Class<? extends T>, BiConsumer<? extends T, GeyserSession>> MAP = new HashMap<>();
|
||||
|
||||
public static final Registry<Packet> JAVA = new Registry<>();
|
||||
|
|
|
@ -46,6 +46,7 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.IOException;
|
||||
|
||||
public class TranslatorsInit {
|
||||
|
||||
private static final CompoundTag EMPTY_TAG = CompoundTagBuilder.builder().buildRootTag();
|
||||
private static final byte[] EMPTY_LEVEL_CHUNK_DATA;
|
||||
|
||||
|
@ -127,15 +128,10 @@ public class TranslatorsInit {
|
|||
session.getUpstream().sendPacket(startGamePacket);
|
||||
|
||||
Vector3f pos = new Vector3f(0, 0, 0);
|
||||
|
||||
int chunkX = pos.getFloorX() >> 4;
|
||||
|
||||
int chunkZ = pos.getFloorZ() >> 4;
|
||||
|
||||
for (int x = -3; x < 3; x++) {
|
||||
|
||||
for (int z = -3; z < 3; z++) {
|
||||
|
||||
LevelChunkPacket data = new LevelChunkPacket();
|
||||
data.setChunkX(chunkX + x);
|
||||
data.setChunkZ(chunkZ + z);
|
||||
|
@ -146,14 +142,11 @@ public class TranslatorsInit {
|
|||
session.getUpstream().sendPacketImmediately(data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PlayStatusPacket packet1 = new PlayStatusPacket();
|
||||
|
||||
packet1.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
|
||||
|
||||
session.getUpstream().sendPacket(packet1);
|
||||
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
|
||||
playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
|
||||
session.getUpstream().sendPacket(playStatusPacket);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ package org.geysermc.connector.plugin;
|
|||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class PluginYML {
|
||||
|
||||
@JsonProperty("name")
|
||||
String name;
|
||||
|
||||
|
|
|
@ -11,12 +11,10 @@ import java.io.InputStream;
|
|||
import java.util.*;
|
||||
|
||||
public class Toolbox {
|
||||
|
||||
static {
|
||||
|
||||
InputStream stream = Toolbox.class.getClassLoader().getResourceAsStream("cached_pallete.json");
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
ArrayList<LinkedHashMap<String, Object>> entries = new ArrayList<>();
|
||||
|
||||
try {
|
||||
|
@ -26,9 +24,7 @@ public class Toolbox {
|
|||
}
|
||||
|
||||
ByteBuf b = Unpooled.buffer();
|
||||
|
||||
VarInts.writeUnsignedInt(b, entries.size());
|
||||
|
||||
for (Map<String, Object> e : entries) {
|
||||
BedrockUtils.writeString(b, (String) e.get("name"));
|
||||
b.writeShortLE((int) e.get("data"));
|
||||
|
@ -37,16 +33,12 @@ public class Toolbox {
|
|||
|
||||
CACHED_PALLETE = b;
|
||||
|
||||
|
||||
|
||||
|
||||
InputStream stream2 = Toolbox.class.getClassLoader().getResourceAsStream("items.json");
|
||||
if (stream2 == null) {
|
||||
throw new AssertionError("Items Table not found");
|
||||
}
|
||||
|
||||
ObjectMapper mapper2 = new ObjectMapper();
|
||||
|
||||
ArrayList<HashMap> s = new ArrayList<>();
|
||||
try {
|
||||
s = mapper2.readValue(stream2, ArrayList.class);
|
||||
|
@ -55,26 +47,11 @@ public class Toolbox {
|
|||
}
|
||||
|
||||
ArrayList<StartGamePacket.ItemEntry> l = new ArrayList<>();
|
||||
|
||||
for(HashMap e : s) {
|
||||
for (HashMap e : s) {
|
||||
l.add(new StartGamePacket.ItemEntry((String) e.get("name"), (short) ((int) e.get("id"))));
|
||||
}
|
||||
|
||||
ITEMS = l;
|
||||
|
||||
/*ByteBuf serializer;
|
||||
|
||||
serializer = Unpooled.buffer();
|
||||
serializer.writeShortLE(1);
|
||||
GeyserUtils.writeVarIntByteArray(serializer, (chunkdata) -> {
|
||||
GeyserUtils.writeEmptySubChunk(chunkdata);
|
||||
chunkdata.writeZero(512);
|
||||
chunkdata.writeZero(256);
|
||||
chunkdata.writeByte(0);
|
||||
});
|
||||
|
||||
EMPTY_CHUNK = GeyserUtils.readAllBytes(serializer);*/
|
||||
|
||||
}
|
||||
|
||||
public static final Collection<StartGamePacket.ItemEntry> ITEMS;
|
||||
|
@ -82,5 +59,4 @@ public class Toolbox {
|
|||
public static final ByteBuf CACHED_PALLETE;
|
||||
|
||||
//public static final byte[] EMPTY_CHUNK;
|
||||
|
||||
}
|
Loading…
Reference in a new issue