Merge remote-tracking branch 'origin/master'

# Conflicts:
#	connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java
This commit is contained in:
EOT3000 2019-07-21 19:14:09 -04:00
commit 464e9cbd2a
11 changed files with 221 additions and 201 deletions

View file

@ -61,4 +61,11 @@ public interface Logger {
* @param message the message to log
*/
void debug(String message);
/**
* Sets if the logger should print debug messages
*
* @param debug if the logger should print debug messages
*/
void setDebug(boolean debug);
}

View file

@ -49,7 +49,6 @@ import org.geysermc.connector.plugin.GeyserPluginManager;
import org.geysermc.connector.utils.Toolbox;
import java.io.*;
import java.lang.reflect.Field;
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@ -95,12 +94,9 @@ public class GeyserConnector implements Connector {
instance = this;
this.generalThreadPool = Executors.newScheduledThreadPool(32); //TODO: Make configurable value
this.logger = GeyserLogger.DEFAULT;
ConsoleCommandReader consoleReader = new ConsoleCommandReader(this);
consoleReader.startConsole();
logger.info("******************************************");
@ -128,12 +124,13 @@ public class GeyserConnector implements Connector {
shutdown();
}
logger.setDebug(config.isDebugMode());
Toolbox.CACHED_PALLETE.array();
TranslatorsInit.start();
commandMap = new GeyserCommandMap(this);
remoteServer = new RemoteJavaServer(config.getRemote().getAddress(), config.getRemote().getPort());
Geyser.setConnector(this);

View file

@ -39,4 +39,7 @@ public class GeyserConfiguration {
@JsonProperty("max-players")
private int maxPlayers;
@JsonProperty("debug-mode")
private boolean debugMode;
}

View file

@ -37,12 +37,11 @@ import java.util.logging.*;
public class GeyserLogger implements org.geysermc.api.logger.Logger {
private boolean colored = true;
private boolean debug = true;
private boolean debug = false;
public static final GeyserLogger DEFAULT = new GeyserLogger();
private GeyserLogger() {
ConsoleHandler consoleHandler = new ConsoleHandler();
consoleHandler.setLevel(Level.INFO);
consoleHandler.setFormatter(new SimpleFormatter() {
@ -117,7 +116,9 @@ public class GeyserLogger implements org.geysermc.api.logger.Logger {
@Override
public void debug(String message) {
waitFor();
System.out.println(printConsole(ChatColor.GRAY + message, colored));
if (debug)
System.out.println(printConsole(ChatColor.GRAY + message, colored));
}
private synchronized void waitFor() {
@ -130,4 +131,9 @@ public class GeyserLogger implements org.geysermc.api.logger.Logger {
public static String printConsole(String message, boolean colors) {
return colors ? ChatColor.toANSI(message + ChatColor.RESET) : ChatColor.stripColors(message + ChatColor.RESET);
}
@Override
public void setDebug(boolean debug) {
this.debug = debug;
}
}

View file

@ -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;
@ -53,7 +52,7 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
@Override
public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
GeyserLogger.DEFAULT.info(inetSocketAddress + " has pinged you!");
GeyserLogger.DEFAULT.debug(inetSocketAddress + " has pinged you!");
GeyserConfiguration config = connector.getConfig();
BedrockPong pong = new BedrockPong();
pong.setEdition("MCPE");
@ -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);
}
}

View file

@ -25,9 +25,10 @@
package org.geysermc.connector.network;
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;
@ -50,10 +51,9 @@ public class UpstreamPacketHandler implements BedrockPacketHandler {
@Override
public boolean handle(LoginPacket loginPacket) {
System.err.println("Handled " + loginPacket.getClass().getSimpleName());
// TODO: Implement support for multiple protocols
if (loginPacket.getProtocolVersion() != GeyserConnector.BEDROCK_PACKET_CODEC.getProtocolVersion()) {
System.out.println("unsupported");
connector.getLogger().debug("unsupported");
session.getUpstream().disconnect("Unsupported Bedrock version. Are you running an outdated version?");
return true;
}
@ -76,12 +76,8 @@ public class UpstreamPacketHandler implements BedrockPacketHandler {
return true;
}
PlayStatusPacket playStatus = new PlayStatusPacket();
playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS);
session.getUpstream().sendPacketImmediately(playStatus);
ResourcePacksInfoPacket resourcePacksInfo = new ResourcePacksInfoPacket();
@ -91,7 +87,7 @@ public class UpstreamPacketHandler implements BedrockPacketHandler {
@Override
public boolean handle(ResourcePackClientResponsePacket textPacket) {
System.err.println("Handled " + textPacket.getClass().getSimpleName());
connector.getLogger().debug("Handled " + textPacket.getClass().getSimpleName());
switch (textPacket.getStatus()) {
case COMPLETED:
session.connect(connector.getRemoteServer());
@ -113,67 +109,72 @@ public class UpstreamPacketHandler implements BedrockPacketHandler {
@Override
public boolean handle(AdventureSettingsPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AnimatePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
return false;
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
switch (packet.getAction()) {
case SWING_ARM:
ClientPlayerSwingArmPacket swingArmPacket = new ClientPlayerSwingArmPacket(Hand.MAIN_HAND);
session.getDownstream().getSession().send(swingArmPacket);
}
return true;
}
@Override
public boolean handle(BlockEntityDataPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(BlockPickRequestPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(BookEditPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ClientCacheBlobStatusPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ClientCacheMissResponsePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ClientCacheStatusPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ClientToServerHandshakePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(CommandBlockUpdatePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(CommandRequestPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
ClientChatPacket chatPacket = new ClientChatPacket(packet.getCommand());
session.getDownstream().getSession().send(chatPacket);
@ -183,229 +184,229 @@ public class UpstreamPacketHandler implements BedrockPacketHandler {
@Override
public boolean handle(ContainerClosePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(CraftingEventPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(EntityEventPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(EntityFallPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(EntityPickRequestPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(EventPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(InteractPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(InventoryContentPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(InventorySlotPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(InventoryTransactionPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ItemFrameDropItemPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LabTablePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LecternUpdatePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LevelEventGenericPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LevelSoundEventPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LevelSoundEvent3Packet packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(MapInfoRequestPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(MobArmorEquipmentPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(MobEquipmentPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ModalFormResponsePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(MoveEntityAbsolutePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(MovePlayerPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(NetworkStackLatencyPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PhotoTransferPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PlayerActionPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PlayerHotbarPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PlayerInputPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PlayerSkinPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PurchaseReceiptPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(RequestChunkRadiusPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ResourcePackChunkRequestPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(RiderJumpPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ServerSettingsRequestPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetDefaultGameTypePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetLocalPlayerAsInitializedPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetPlayerGameTypePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SubClientLoginPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(TextPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
if(packet.getMessage().charAt(0) == '.') {
@ -426,493 +427,493 @@ public class UpstreamPacketHandler implements BedrockPacketHandler {
@Override
public boolean handle(AddBehaviorTreePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AddEntityPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AddHangingEntityPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AddItemEntityPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AddPaintingPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AddPlayerPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AvailableCommandsPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(BlockEventPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(BossEventPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(CameraPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ChangeDimensionPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ChunkRadiusUpdatedPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ClientboundMapItemDataPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(CommandOutputPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ContainerOpenPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ContainerSetDataPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(CraftingDataPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(DisconnectPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ExplodePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LevelChunkPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(GameRulesChangedPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(GuiDataPickItemPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(HurtArmorPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AutomationClientConnectPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LevelEventPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(MapCreateLockedCopyPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(MobEffectPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ModalFormRequestPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(MoveEntityDeltaPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(NpcRequestPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(OnScreenTextureAnimationPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PlayerListPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PlaySoundPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PlayStatusPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(RemoveEntityPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(RemoveObjectivePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ResourcePackChunkDataPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ResourcePackDataInfoPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ResourcePacksInfoPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ResourcePackStackPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(RespawnPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ScriptCustomEventPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ServerSettingsResponsePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ServerToClientHandshakePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetCommandsEnabledPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetDifficultyPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetDisplayObjectivePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetEntityDataPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetEntityLinkPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetEntityMotionPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetHealthPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetLastHurtByPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetScoreboardIdentityPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetScorePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetSpawnPositionPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetTimePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetTitlePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ShowCreditsPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ShowProfilePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ShowStoreOfferPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SimpleEventPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SpawnExperienceOrbPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(StartGamePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(StopSoundPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(StructureBlockUpdatePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(StructureTemplateDataExportRequestPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(StructureTemplateDataExportResponsePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(TakeItemEntityPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(TransferPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(UpdateAttributesPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(UpdateBlockPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(UpdateBlockPropertiesPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(UpdateBlockSyncedPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(UpdateEquipPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(UpdateSoftEnumPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(UpdateTradePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AvailableEntityIdentifiersPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(BiomeDefinitionListPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LevelSoundEvent2Packet packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(NetworkChunkPublisherUpdatePacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SpawnParticleEffectPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(VideoStreamConnectPacket packet) {
System.out.println("Handled packet: " + packet.getClass().getSimpleName());
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
}

View file

@ -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<>();
@ -48,7 +47,7 @@ public class Registry<T> {
try {
((BiConsumer<P, GeyserSession>) JAVA.MAP.get(clazz)).accept(p, s);
} catch (NullPointerException e) {
GeyserLogger.DEFAULT.warning("could not translate packet " + p.getClass().getSimpleName());
GeyserLogger.DEFAULT.debug("could not translate packet " + p.getClass().getSimpleName());
}
}
}

View file

@ -26,32 +26,28 @@
package org.geysermc.connector.network.translators;
import com.flowpowered.math.vector.Vector2f;
import com.flowpowered.math.vector.Vector2i;
import com.flowpowered.math.vector.Vector3f;
import com.flowpowered.math.vector.Vector3i;
import com.github.steveice10.mc.protocol.data.message.TranslationMessage;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerTitlePacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateTimePacket;
import com.nukkitx.nbt.CompoundTagBuilder;
import com.nukkitx.nbt.NbtUtils;
import com.nukkitx.nbt.stream.NBTOutputStream;
import com.nukkitx.nbt.tag.CompoundTag;
import com.nukkitx.network.VarInts;
import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
import com.nukkitx.protocol.bedrock.data.GameRule;
import com.nukkitx.protocol.bedrock.packet.*;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.buffer.Unpooled;
import org.geysermc.connector.utils.GeyserUtils;
import org.geysermc.connector.utils.MessageUtils;
import org.geysermc.connector.utils.Toolbox;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
public class TranslatorsInit {
private static final CompoundTag EMPTY_TAG = CompoundTagBuilder.builder().buildRootTag();
private static final byte[] EMPTY_LEVEL_CHUNK_DATA;
@ -72,6 +68,8 @@ public class TranslatorsInit {
public static void start() {
addLoginPackets();
addChatPackets();
addTitlePackets();
addTimePackets();
}
private static void addLoginPackets() {
@ -132,15 +130,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);
@ -151,14 +144,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);
});
}
@ -167,7 +157,7 @@ public class TranslatorsInit {
TextPacket textPacket = new TextPacket();
textPacket.setPlatformChatId("");
textPacket.setSourceName("");
textPacket.setXuid("");
textPacket.setXuid(session.getAuthenticationData().getXboxUUID());
switch (packet.getType()) {
case CHAT:
textPacket.setType(TextPacket.Type.CHAT);
@ -192,4 +182,45 @@ public class TranslatorsInit {
session.getUpstream().sendPacket(textPacket);
});
}
public static void addTitlePackets() {
Registry.add(ServerTitlePacket.class, (packet, session) -> {
SetTitlePacket titlePacket = new SetTitlePacket();
switch (packet.getAction()) {
case TITLE:
titlePacket.setType(SetTitlePacket.Type.SET_TITLE);
titlePacket.setText(packet.getTitle().getFullText());
break;
case SUBTITLE:
titlePacket.setType(SetTitlePacket.Type.SET_SUBTITLE);
titlePacket.setText(packet.getSubtitle().getFullText());
break;
case CLEAR:
case RESET:
titlePacket.setType(SetTitlePacket.Type.RESET_TITLE);
titlePacket.setText("");
break;
case ACTION_BAR:
titlePacket.setType(SetTitlePacket.Type.SET_ACTIONBAR_MESSAGE);
titlePacket.setText(packet.getActionBar().getFullText());
break;
}
titlePacket.setFadeInTime(packet.getFadeIn());
titlePacket.setFadeOutTime(packet.getFadeOut());
titlePacket.setStayTime(packet.getStay());
session.getUpstream().sendPacket(titlePacket);
});
}
public static void addTimePackets() {
Registry.add(ServerUpdateTimePacket.class, (packet, session) -> {
SetTimePacket setTimePacket = new SetTimePacket();
setTimePacket.setTime((int) Math.abs(packet.getTime()));
session.getUpstream().sendPacket(setTimePacket);
});
}
}

View file

@ -28,6 +28,7 @@ package org.geysermc.connector.plugin;
import com.fasterxml.jackson.annotation.JsonProperty;
public class PluginYML {
@JsonProperty("name")
String name;

View file

@ -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;
}

View file

@ -27,6 +27,9 @@ ping-passthrough: false
# Maximum amount of players that can connect
max-players: 100
# If debug messages should be sent through console
debug-mode: false