Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-03 14:50:19 +01:00
Merge branch 'master' of https://github.com/GeyserMC/Geyser into floodgate-2.0
Dieser Commit ist enthalten in:
Commit
946f38c00a
@ -5,7 +5,7 @@
|
|||||||
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
|
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
|
||||||
[![Build Status](https://ci.opencollab.dev/job/Geyser/job/master/badge/icon)](https://ci.opencollab.dev/job/GeyserMC/job/Geyser/job/master/)
|
[![Build Status](https://ci.opencollab.dev/job/Geyser/job/master/badge/icon)](https://ci.opencollab.dev/job/GeyserMC/job/Geyser/job/master/)
|
||||||
[![Discord](https://img.shields.io/discord/613163671870242838.svg?color=%237289da&label=discord)](http://discord.geysermc.org/)
|
[![Discord](https://img.shields.io/discord/613163671870242838.svg?color=%237289da&label=discord)](http://discord.geysermc.org/)
|
||||||
[![HitCount](http://hits.dwyl.io/Geyser/GeyserMC.svg)](http://hits.dwyl.io/Geyser/GeyserMC)
|
[![HitCount](http://hits.dwyl.com/Geyser/GeyserMC.svg)](http://hits.dwyl.com/Geyser/GeyserMC)
|
||||||
[![Crowdin](https://badges.crowdin.net/geyser/localized.svg)](https://translate.geysermc.org/)
|
[![Crowdin](https://badges.crowdin.net/geyser/localized.svg)](https://translate.geysermc.org/)
|
||||||
|
|
||||||
Geyser is a bridge between Minecraft: Bedrock Edition and Minecraft: Java Edition, closing the gap from those wanting to play true cross-platform.
|
Geyser is a bridge between Minecraft: Bedrock Edition and Minecraft: Java Edition, closing the gap from those wanting to play true cross-platform.
|
||||||
|
@ -62,6 +62,7 @@ import org.geysermc.floodgate.crypto.AesCipher;
|
|||||||
import org.geysermc.floodgate.crypto.AesKeyProducer;
|
import org.geysermc.floodgate.crypto.AesKeyProducer;
|
||||||
import org.geysermc.floodgate.crypto.Base64Topping;
|
import org.geysermc.floodgate.crypto.Base64Topping;
|
||||||
import org.geysermc.floodgate.crypto.FloodgateCipher;
|
import org.geysermc.floodgate.crypto.FloodgateCipher;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
|
||||||
import javax.naming.directory.Attribute;
|
import javax.naming.directory.Attribute;
|
||||||
import javax.naming.directory.InitialDirContext;
|
import javax.naming.directory.InitialDirContext;
|
||||||
@ -372,9 +373,14 @@ public class GeyserConnector {
|
|||||||
* @param uuid the uuid
|
* @param uuid the uuid
|
||||||
* @return the player or <code>null</code> if there is no player online with this UUID
|
* @return the player or <code>null</code> if there is no player online with this UUID
|
||||||
*/
|
*/
|
||||||
|
@Contract("null -> null")
|
||||||
public GeyserSession getPlayerByUuid(UUID uuid) {
|
public GeyserSession getPlayerByUuid(UUID uuid) {
|
||||||
|
if (uuid == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
for (GeyserSession session : players) {
|
for (GeyserSession session : players) {
|
||||||
if (session.getPlayerEntity().getUuid().equals(uuid)) {
|
if (uuid.equals(session.getPlayerEntity().getUuid())) {
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,14 @@ package org.geysermc.connector.entity.player;
|
|||||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import com.nukkitx.math.vector.Vector3i;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.command.CommandPermission;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||||
|
import com.nukkitx.protocol.bedrock.packet.AddPlayerPacket;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,6 +65,33 @@ public class SkullPlayerEntity extends PlayerEntity {
|
|||||||
metadata.getFlags().setFlag(EntityFlag.INVISIBLE, true); // Until the skin is loaded
|
metadata.getFlags().setFlag(EntityFlag.INVISIBLE, true); // Until the skin is loaded
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overwritten so each entity doesn't check for a linked entity
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void spawnEntity(GeyserSession session) {
|
||||||
|
AddPlayerPacket addPlayerPacket = new AddPlayerPacket();
|
||||||
|
addPlayerPacket.setUuid(getUuid());
|
||||||
|
addPlayerPacket.setUsername(getUsername());
|
||||||
|
addPlayerPacket.setRuntimeEntityId(geyserId);
|
||||||
|
addPlayerPacket.setUniqueEntityId(geyserId);
|
||||||
|
addPlayerPacket.setPosition(position.clone().sub(0, EntityType.PLAYER.getOffset(), 0));
|
||||||
|
addPlayerPacket.setRotation(getBedrockRotation());
|
||||||
|
addPlayerPacket.setMotion(motion);
|
||||||
|
addPlayerPacket.setHand(hand);
|
||||||
|
addPlayerPacket.getAdventureSettings().setCommandPermission(CommandPermission.NORMAL);
|
||||||
|
addPlayerPacket.getAdventureSettings().setPlayerPermission(PlayerPermission.MEMBER);
|
||||||
|
addPlayerPacket.setDeviceId("");
|
||||||
|
addPlayerPacket.setPlatformChatId("");
|
||||||
|
addPlayerPacket.getMetadata().putAll(metadata);
|
||||||
|
|
||||||
|
valid = true;
|
||||||
|
session.sendUpstreamPacket(addPlayerPacket);
|
||||||
|
|
||||||
|
updateEquipment(session);
|
||||||
|
updateBedrockAttributes(session);
|
||||||
|
}
|
||||||
|
|
||||||
public void despawnEntity(GeyserSession session, Vector3i position) {
|
public void despawnEntity(GeyserSession session, Vector3i position) {
|
||||||
this.despawnEntity(session);
|
this.despawnEntity(session);
|
||||||
session.getSkullCache().remove(position, this);
|
session.getSkullCache().remove(position, this);
|
||||||
|
@ -98,7 +98,6 @@ import org.geysermc.cumulus.util.FormBuilder;
|
|||||||
import org.geysermc.floodgate.crypto.FloodgateCipher;
|
import org.geysermc.floodgate.crypto.FloodgateCipher;
|
||||||
import org.geysermc.floodgate.util.BedrockData;
|
import org.geysermc.floodgate.util.BedrockData;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@ -672,7 +671,16 @@ public class GeyserSession implements CommandSender {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.network.remote.connect", authData.getName(), protocol.getProfile().getName(), remoteAddress));
|
connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.network.remote.connect", authData.getName(), protocol.getProfile().getName(), remoteAddress));
|
||||||
playerEntity.setUuid(protocol.getProfile().getId());
|
UUID uuid = protocol.getProfile().getId();
|
||||||
|
if (uuid == null) {
|
||||||
|
// Set what our UUID *probably* is going to be
|
||||||
|
if (remoteAuthType == AuthType.FLOODGATE) {
|
||||||
|
uuid = new UUID(0, Long.parseLong(authData.getXboxUUID()));
|
||||||
|
} else {
|
||||||
|
uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + protocol.getProfile().getName()).getBytes(StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
playerEntity.setUuid(uuid);
|
||||||
playerEntity.setUsername(protocol.getProfile().getName());
|
playerEntity.setUsername(protocol.getProfile().getName());
|
||||||
|
|
||||||
String locale = clientData.getLanguageCode();
|
String locale = clientData.getLanguageCode();
|
||||||
|
@ -59,6 +59,7 @@ public class EntityCache {
|
|||||||
|
|
||||||
public EntityCache(GeyserSession session) {
|
public EntityCache(GeyserSession session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
cachedPlayerEntityLinks.defaultReturnValue(-1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnEntity(Entity entity) {
|
public void spawnEntity(Entity entity) {
|
||||||
@ -100,6 +101,9 @@ public class EntityCache {
|
|||||||
for (Entity entity : entities) {
|
for (Entity entity : entities) {
|
||||||
session.getEntityCache().removeEntity(entity, false);
|
session.getEntityCache().removeEntity(entity, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// As a precaution
|
||||||
|
cachedPlayerEntityLinks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity getEntityByGeyserId(long geyserId) {
|
public Entity getEntityByGeyserId(long geyserId) {
|
||||||
@ -160,7 +164,7 @@ public class EntityCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long getCachedPlayerEntityLink(long playerId) {
|
public long getCachedPlayerEntityLink(long playerId) {
|
||||||
return cachedPlayerEntityLinks.getOrDefault(playerId, -1);
|
return cachedPlayerEntityLinks.remove(playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCachedPlayerEntityLink(long playerId, long linkedEntityId) {
|
public void addCachedPlayerEntityLink(long playerId, long linkedEntityId) {
|
||||||
|
@ -47,9 +47,11 @@ public class JavaEntitySetPassengersTranslator extends PacketTranslator<ServerEn
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(ServerEntitySetPassengersPacket packet, GeyserSession session) {
|
public void translate(ServerEntitySetPassengersPacket packet, GeyserSession session) {
|
||||||
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
Entity entity;
|
||||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||||
entity = session.getPlayerEntity();
|
entity = session.getPlayerEntity();
|
||||||
|
} else {
|
||||||
|
entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
@ -66,7 +68,8 @@ public class JavaEntitySetPassengersTranslator extends PacketTranslator<ServerEn
|
|||||||
session.confirmTeleport(passenger.getPosition().sub(0, EntityType.PLAYER.getOffset(), 0).toDouble());
|
session.confirmTeleport(passenger.getPosition().sub(0, EntityType.PLAYER.getOffset(), 0).toDouble());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Passenger hasn't loaded in and entity link needs to be set later
|
// Passenger hasn't loaded in (likely since we're waiting for a skin response)
|
||||||
|
// and entity link needs to be set later
|
||||||
if (passenger == null && passengerId != 0) {
|
if (passenger == null && passengerId != 0) {
|
||||||
session.getEntityCache().addCachedPlayerEntityLink(passengerId, packet.getEntityId());
|
session.getEntityCache().addCachedPlayerEntityLink(passengerId, packet.getEntityId());
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren