forked from GeyserMC/Geyser
Merge remote-tracking branch 'origin/master'
# Conflicts: # connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
This commit is contained in:
commit
a2e4aed340
2 changed files with 39 additions and 15 deletions
|
@ -176,8 +176,13 @@ public class UpstreamPacketHandler implements BedrockPacketHandler {
|
||||||
public boolean handle(CommandRequestPacket packet) {
|
public boolean handle(CommandRequestPacket packet) {
|
||||||
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
|
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
|
||||||
|
|
||||||
|
String command = packet.getCommand().replace("/", "");
|
||||||
|
if (connector.getCommandMap().getCommands().containsKey(command)) {
|
||||||
|
connector.getCommandMap().runCommand(session, command);
|
||||||
|
} else {
|
||||||
ClientChatPacket chatPacket = new ClientChatPacket(packet.getCommand());
|
ClientChatPacket chatPacket = new ClientChatPacket(packet.getCommand());
|
||||||
session.getDownstream().getSession().send(chatPacket);
|
session.getDownstream().getSession().send(chatPacket);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -408,18 +413,13 @@ public class UpstreamPacketHandler implements BedrockPacketHandler {
|
||||||
public boolean handle(TextPacket packet) {
|
public boolean handle(TextPacket packet) {
|
||||||
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
|
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
|
||||||
|
|
||||||
if(packet.getMessage().charAt(0) == '.') {
|
if (packet.getMessage().charAt(0) == '.') {
|
||||||
|
|
||||||
ClientChatPacket chatPacket = new ClientChatPacket(packet.getMessage().replace(".", "/"));
|
ClientChatPacket chatPacket = new ClientChatPacket(packet.getMessage().replace(".", "/"));
|
||||||
|
|
||||||
session.getDownstream().getSession().send(chatPacket);
|
session.getDownstream().getSession().send(chatPacket);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientChatPacket chatPacket = new ClientChatPacket(packet.getMessage());
|
ClientChatPacket chatPacket = new ClientChatPacket(packet.getMessage());
|
||||||
|
|
||||||
session.getDownstream().getSession().send(chatPacket);
|
session.getDownstream().getSession().send(chatPacket);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -31,22 +31,21 @@ import com.github.steveice10.packetlib.event.session.ConnectedEvent;
|
||||||
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
|
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
|
||||||
import com.github.steveice10.packetlib.event.session.PacketReceivedEvent;
|
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.tcp.TcpSessionFactory;
|
import com.github.steveice10.packetlib.tcp.TcpSessionFactory;
|
||||||
import com.nukkitx.network.util.DisconnectReason;
|
import com.nukkitx.network.util.DisconnectReason;
|
||||||
import com.nukkitx.protocol.PlayerSession;
|
import com.nukkitx.protocol.PlayerSession;
|
||||||
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
||||||
|
import com.nukkitx.protocol.bedrock.packet.TextPacket;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.api.session.AuthData;
|
import org.geysermc.api.command.CommandSender;
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.network.remote.RemoteJavaServer;
|
import org.geysermc.connector.network.remote.RemoteJavaServer;
|
||||||
import org.geysermc.connector.network.translators.Registry;
|
import org.geysermc.connector.network.translators.Registry;
|
||||||
import sun.security.krb5.internal.AuthorizationData;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class GeyserSession implements PlayerSession {
|
public class GeyserSession implements PlayerSession, CommandSender {
|
||||||
|
|
||||||
private GeyserConnector connector;
|
private GeyserConnector connector;
|
||||||
|
|
||||||
|
@ -128,12 +127,37 @@ public class GeyserSession implements PlayerSession {
|
||||||
authenticationData = new AuthenticationData(name, uuid, xboxUUID);
|
authenticationData = new AuthenticationData(name, uuid, xboxUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return authenticationData.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(String message) {
|
||||||
|
TextPacket textPacket = new TextPacket();
|
||||||
|
textPacket.setPlatformChatId("");
|
||||||
|
textPacket.setSourceName("");
|
||||||
|
textPacket.setXuid("");
|
||||||
|
textPacket.setType(TextPacket.Type.CHAT);
|
||||||
|
textPacket.setNeedsTranslation(false);
|
||||||
|
textPacket.setMessage(message);
|
||||||
|
|
||||||
|
upstream.sendPacket(textPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(String[] messages) {
|
||||||
|
for (String message : messages) {
|
||||||
|
sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class AuthenticationData implements AuthData {
|
public class AuthenticationData {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private UUID UUID;
|
private UUID uuid;
|
||||||
private String XUID;
|
private String xboxUUID;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue