3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 08:30:12 +01:00

Update to latest master

Dieser Commit ist enthalten in:
DoctorMacc 2020-07-29 16:25:42 -04:00
Commit 43c062c23c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6D6E7E059F186DB4
12 geänderte Dateien mit 113 neuen und 41 gelöschten Zeilen

38
.gitignore vendored
Datei anzeigen

@ -1,6 +1,6 @@
# Created by https://www.gitignore.io/api/git,java,maven,eclipse,netbeans,jetbrains+all # Created by https://www.gitignore.io/api/git,java,maven,eclipse,netbeans,jetbrains+all,visualstudiocode
# Edit at https://www.gitignore.io/?templates=git,java,maven,eclipse,netbeans,jetbrains+all # Edit at https://www.gitignore.io/gitignore?templates=git,java,maven,eclipse,netbeans,jetbrains+all,visualstudiocode
### Eclipse ### ### Eclipse ###
.metadata .metadata
@ -53,22 +53,19 @@ local.properties
# Annotation Processing # Annotation Processing
.apt_generated/ .apt_generated/
.apt_generated_test/
# Scala IDE specific (Scala & Java development for Eclipse) # Scala IDE specific (Scala & Java development for Eclipse)
.cache-main .cache-main
.scala_dependencies .scala_dependencies
.worksheet .worksheet
### Eclipse Patch ### # Uncomment this line if you wish to ignore the project description file.
# Eclipse Core # Typically, this file would be tracked if it contains build/dependency configurations:
.project .project
# JDT-specific (Eclipse Java Development Tools) ### Eclipse Patch ###
.classpath # Spring Boot Tooling
# Annotation Processing
.apt_generated
.sts4-cache/ .sts4-cache/
### Git ### ### Git ###
@ -112,7 +109,7 @@ local.properties
hs_err_pid* hs_err_pid*
### JetBrains+all ### ### JetBrains+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff # User-specific stuff
@ -142,6 +139,9 @@ hs_err_pid*
# When using Gradle or Maven with auto-import, you should exclude module files, # When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using # since they will be recreated, and may cause churn. Uncomment if using
# auto-import. # auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml # .idea/modules.xml
# .idea/*.iml # .idea/*.iml
# .idea/modules # .idea/modules
@ -207,6 +207,7 @@ release.properties
dependency-reduced-pom.xml dependency-reduced-pom.xml
buildNumber.properties buildNumber.properties
.mvn/timing.properties .mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar .mvn/wrapper/maven-wrapper.jar
### NetBeans ### ### NetBeans ###
@ -219,7 +220,20 @@ dist/
nbdist/ nbdist/
.nb-gradle/ .nb-gradle/
# End of https://www.gitignore.io/api/git,java,maven,eclipse,netbeans,jetbrains+all ### VisualStudioCode ###
# Note: Manually edited to remove settings files
.vscode/*
# !.vscode/settings.json
# !.vscode/tasks.json
# !.vscode/launch.json
# !.vscode/extensions.json
# *.code-workspace
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
# End of https://www.gitignore.io/api/git,java,maven,eclipse,netbeans,jetbrains+all,visualstudiocode
### Geyser ### ### Geyser ###
run/ run/

Datei anzeigen

@ -195,11 +195,21 @@ public class GeyserSpongeConfiguration implements GeyserConfiguration {
return node.getNode("address").getString("127.0.0.1"); return node.getNode("address").getString("127.0.0.1");
} }
@Override
public void setAddress(String address) {
node.getNode("address").setValue(address);
}
@Override @Override
public int getPort() { public int getPort() {
return node.getNode("port").getInt(25565); return node.getNode("port").getInt(25565);
} }
@Override
public void setPort(int port) {
node.getNode("port").setValue(port);
}
@Override @Override
public String getAuthType() { public String getAuthType() {
return node.getNode("auth-type").getString("online"); return node.getNode("auth-type").getString("online");

Datei anzeigen

@ -58,6 +58,8 @@ import org.geysermc.connector.utils.DockerCheck;
import org.geysermc.connector.utils.LanguageUtils; import org.geysermc.connector.utils.LanguageUtils;
import org.geysermc.connector.utils.LocaleUtils; import org.geysermc.connector.utils.LocaleUtils;
import javax.naming.directory.Attribute;
import javax.naming.directory.InitialDirContext;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -77,6 +79,8 @@ public class GeyserConnector {
public static final String NAME = "Geyser"; public static final String NAME = "Geyser";
public static final String VERSION = "DEV"; // A fallback for running in IDEs public static final String VERSION = "DEV"; // A fallback for running in IDEs
private static final String IP_REGEX = "\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b";
private final List<GeyserSession> players = new ArrayList<>(); private final List<GeyserSession> players = new ArrayList<>();
private static GeyserConnector instance; private static GeyserConnector instance;
@ -135,8 +139,30 @@ public class GeyserConnector {
if (platformType != PlatformType.STANDALONE) { if (platformType != PlatformType.STANDALONE) {
DockerCheck.check(bootstrap); DockerCheck.check(bootstrap);
} }
String remoteAddress = config.getRemote().getAddress();
int remotePort = config.getRemote().getPort();
// Filters whether it is not an IP address or localhost, because otherwise it is not possible to find out an SRV entry.
if ((config.isLegacyPingPassthrough() || platformType == PlatformType.STANDALONE) && !remoteAddress.matches(IP_REGEX) && !remoteAddress.equalsIgnoreCase("localhost")) {
try {
// Searches for a server address and a port from a SRV record of the specified host name
InitialDirContext ctx = new InitialDirContext();
Attribute attr = ctx.getAttributes("dns:///_minecraft._tcp." + remoteAddress, new String[]{"SRV"}).get("SRV");
// size > 0 = SRV entry found
if (attr != null && attr.size() > 0) {
String[] record = ((String) attr.get(0)).split(" ");
// Overwrites the existing address and port with that from the SRV record.
config.getRemote().setAddress(remoteAddress = record[3]);
config.getRemote().setPort(remotePort = Integer.parseInt(record[2]));
logger.debug("Found SRV record \"" + remoteAddress + ":" + remotePort + "\"");
}
} catch (Exception ex) {
logger.debug("Exception while trying to find an SRV record for the remote host.");
if (config.isDebugMode())
ex.printStackTrace(); // Otherwise we can get a stack trace for any domain that doesn't have an SRV record
}
}
remoteServer = new RemoteServer(config.getRemote().getAddress(), config.getRemote().getPort()); remoteServer = new RemoteServer(config.getRemote().getAddress(), remotePort);
authType = AuthType.getByName(config.getRemote().getAuthType()); authType = AuthType.getByName(config.getRemote().getAuthType());
if (config.isAboveBedrockNetherBuilding()) if (config.isAboveBedrockNetherBuilding())

Datei anzeigen

@ -93,6 +93,10 @@ public interface GeyserConfiguration {
int getPort(); int getPort();
void setAddress(String address);
void setPort(int port);
String getAuthType(); String getAuthType();
} }

Datei anzeigen

@ -59,7 +59,12 @@ public class WolfEntity extends TameableEntity {
if (entityMetadata.getId() == 19 && !metadata.getFlags().getFlag(EntityFlag.ANGRY)) { if (entityMetadata.getId() == 19 && !metadata.getFlags().getFlag(EntityFlag.ANGRY)) {
metadata.put(EntityData.COLOR, (byte) (int) entityMetadata.getValue()); metadata.put(EntityData.COLOR, (byte) (int) entityMetadata.getValue());
} }
//TODO: Anger time int?
// Wolf anger (1.16+)
if (entityMetadata.getId() == 20) {
metadata.getFlags().setFlag(EntityFlag.ANGRY, (int) entityMetadata.getValue() != 0);
}
super.updateBedrockMetadata(entityMetadata, session); super.updateBedrockMetadata(entityMetadata, session);
} }
} }

Datei anzeigen

@ -135,12 +135,15 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
} }
break; break;
case OPEN_INVENTORY: case OPEN_INVENTORY:
if (!session.getInventory().isOpen()) {
ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket(); ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket();
containerOpenPacket.setId((byte) 0); containerOpenPacket.setId((byte) 0);
containerOpenPacket.setType(ContainerType.INVENTORY); containerOpenPacket.setType(ContainerType.INVENTORY);
containerOpenPacket.setUniqueEntityId(-1); containerOpenPacket.setUniqueEntityId(-1);
containerOpenPacket.setBlockPosition(entity.getPosition().toInt()); containerOpenPacket.setBlockPosition(entity.getPosition().toInt());
session.sendUpstreamPacket(containerOpenPacket); session.sendUpstreamPacket(containerOpenPacket);
session.getInventory().setOpen(true);
}
break; break;
} }
} }

Datei anzeigen

@ -60,7 +60,8 @@ public class MerchantInventoryTranslator extends BaseInventoryTranslator {
@Override @Override
public int bedrockSlotToJava(InventoryActionData action) { public int bedrockSlotToJava(InventoryActionData action) {
if (action.getSource().getContainerId() == ContainerId.UI) { switch (action.getSource().getContainerId()) {
case ContainerId.UI:
switch (action.getSlot()) { switch (action.getSlot()) {
case 4: case 4:
return 0; return 0;
@ -69,6 +70,13 @@ public class MerchantInventoryTranslator extends BaseInventoryTranslator {
case 50: case 50:
return 2; return 2;
} }
break;
case -28: // Trading 1?
return 0;
case -29: // Trading 2?
return 1;
case -30: // Trading Output?
return 2;
} }
return super.bedrockSlotToJava(action); return super.bedrockSlotToJava(action);
} }
@ -109,11 +117,9 @@ public class MerchantInventoryTranslator extends BaseInventoryTranslator {
@Override @Override
public void translateActions(GeyserSession session, Inventory inventory, List<InventoryActionData> actions) { public void translateActions(GeyserSession session, Inventory inventory, List<InventoryActionData> actions) {
for (InventoryActionData action : actions) { if (actions.stream().anyMatch(a -> a.getSource().getContainerId() == -31)) {
if (action.getSource().getType() == InventorySource.Type.NON_IMPLEMENTED_TODO) {
return; return;
} }
}
super.translateActions(session, inventory, actions); super.translateActions(session, inventory, actions);
} }

Datei anzeigen

@ -62,7 +62,7 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator<Serve
RespawnPacket respawnPacket = new RespawnPacket(); RespawnPacket respawnPacket = new RespawnPacket();
respawnPacket.setRuntimeEntityId(entity.getGeyserId()); respawnPacket.setRuntimeEntityId(entity.getGeyserId());
respawnPacket.setPosition(pos); respawnPacket.setPosition(entity.getPosition());
respawnPacket.setState(RespawnPacket.State.SERVER_READY); respawnPacket.setState(RespawnPacket.State.SERVER_READY);
session.sendUpstreamPacket(respawnPacket); session.sendUpstreamPacket(respawnPacket);
@ -79,7 +79,7 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator<Serve
MovePlayerPacket movePlayerPacket = new MovePlayerPacket(); MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
movePlayerPacket.setRuntimeEntityId(entity.getGeyserId()); movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
movePlayerPacket.setPosition(pos); movePlayerPacket.setPosition(entity.getPosition());
movePlayerPacket.setRotation(Vector3f.from(packet.getPitch(), packet.getYaw(), 0)); movePlayerPacket.setRotation(Vector3f.from(packet.getPitch(), packet.getYaw(), 0));
movePlayerPacket.setMode(MovePlayerPacket.Mode.RESPAWN); //TODO: PROBABLY RIGHT BUT STILL CHECK movePlayerPacket.setMode(MovePlayerPacket.Mode.RESPAWN); //TODO: PROBABLY RIGHT BUT STILL CHECK

Datei anzeigen

@ -85,6 +85,7 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
playerFlags.add(AdventureSetting.MAY_FLY); playerFlags.add(AdventureSetting.MAY_FLY);
playerFlags.add(AdventureSetting.NO_CLIP); playerFlags.add(AdventureSetting.NO_CLIP);
playerFlags.add(AdventureSetting.FLYING); playerFlags.add(AdventureSetting.FLYING);
playerFlags.add(AdventureSetting.WORLD_IMMUTABLE);
gameMode = GameMode.CREATIVE; // spectator doesnt exist on bedrock gameMode = GameMode.CREATIVE; // spectator doesnt exist on bedrock
} }

Datei anzeigen

@ -79,15 +79,17 @@ public class GeyserLegacyPingPassthrough implements IGeyserPingPassthrough, Runn
public void run() { public void run() {
try { try {
Socket socket = new Socket(); Socket socket = new Socket();
socket.connect(new InetSocketAddress(connector.getConfig().getRemote().getAddress(), connector.getConfig().getRemote().getPort()), 5000); String address = connector.getConfig().getRemote().getAddress();
int port = connector.getConfig().getRemote().getPort();
socket.connect(new InetSocketAddress(address, port), 5000);
ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream(); ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream();
DataOutputStream handshake = new DataOutputStream(byteArrayStream); DataOutputStream handshake = new DataOutputStream(byteArrayStream);
handshake.write(0x0); handshake.write(0x0);
VarInts.writeUnsignedInt(handshake, MinecraftConstants.PROTOCOL_VERSION); VarInts.writeUnsignedInt(handshake, MinecraftConstants.PROTOCOL_VERSION);
VarInts.writeUnsignedInt(handshake, socket.getInetAddress().getHostAddress().length()); VarInts.writeUnsignedInt(handshake, address.length());
handshake.writeBytes(socket.getInetAddress().getHostAddress()); handshake.writeBytes(address);
handshake.writeShort(socket.getPort()); handshake.writeShort(port);
VarInts.writeUnsignedInt(handshake, 1); VarInts.writeUnsignedInt(handshake, 1);
DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream()); DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());

Datei anzeigen

@ -56,7 +56,7 @@ public class InventoryUtils {
translator.prepareInventory(session, inventory); translator.prepareInventory(session, inventory);
//Ensure at least half a second passes between closing and opening a new window //Ensure at least half a second passes between closing and opening a new window
//The client will not open the new window if it is still closing the old one //The client will not open the new window if it is still closing the old one
long delay = 500 - (System.currentTimeMillis() - session.getLastWindowCloseTime()); long delay = 700 - (System.currentTimeMillis() - session.getLastWindowCloseTime());
//TODO: find better way to handle double chest delay //TODO: find better way to handle double chest delay
if (translator instanceof DoubleChestInventoryTranslator) { if (translator instanceof DoubleChestInventoryTranslator) {
delay = Math.max(delay, 200); delay = Math.max(delay, 200);
@ -87,6 +87,7 @@ public class InventoryUtils {
} }
} else { } else {
Inventory inventory = session.getInventory(); Inventory inventory = session.getInventory();
inventory.setOpen(false);
InventoryTranslator translator = InventoryTranslator.INVENTORY_TRANSLATORS.get(inventory.getWindowType()); InventoryTranslator translator = InventoryTranslator.INVENTORY_TRANSLATORS.get(inventory.getWindowType());
translator.updateInventory(session, inventory); translator.updateInventory(session, inventory);
} }

@ -1 +1 @@
Subproject commit 8a62f3730bd1ae94262315ad1535b5d5523de189 Subproject commit cd57d6029186293b3ca282243a90252db434714b