Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 14:30:17 +01:00
Update to latest master
Dieser Commit ist enthalten in:
Commit
43c062c23c
38
.gitignore
vendored
38
.gitignore
vendored
@ -1,6 +1,6 @@
|
||||
|
||||
# Created by https://www.gitignore.io/api/git,java,maven,eclipse,netbeans,jetbrains+all
|
||||
# Edit at https://www.gitignore.io/?templates=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/gitignore?templates=git,java,maven,eclipse,netbeans,jetbrains+all,visualstudiocode
|
||||
|
||||
### Eclipse ###
|
||||
.metadata
|
||||
@ -53,22 +53,19 @@ local.properties
|
||||
|
||||
# Annotation Processing
|
||||
.apt_generated/
|
||||
.apt_generated_test/
|
||||
|
||||
# Scala IDE specific (Scala & Java development for Eclipse)
|
||||
.cache-main
|
||||
.scala_dependencies
|
||||
.worksheet
|
||||
|
||||
### Eclipse Patch ###
|
||||
# Eclipse Core
|
||||
# Uncomment this line if you wish to ignore the project description file.
|
||||
# Typically, this file would be tracked if it contains build/dependency configurations:
|
||||
.project
|
||||
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
|
||||
# Annotation Processing
|
||||
.apt_generated
|
||||
|
||||
### Eclipse Patch ###
|
||||
# Spring Boot Tooling
|
||||
.sts4-cache/
|
||||
|
||||
### Git ###
|
||||
@ -112,7 +109,7 @@ local.properties
|
||||
hs_err_pid*
|
||||
|
||||
### 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
|
||||
|
||||
# User-specific stuff
|
||||
@ -142,6 +139,9 @@ hs_err_pid*
|
||||
# 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
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
@ -207,6 +207,7 @@ release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
### NetBeans ###
|
||||
@ -219,7 +220,20 @@ dist/
|
||||
nbdist/
|
||||
.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 ###
|
||||
run/
|
||||
|
@ -195,11 +195,21 @@ public class GeyserSpongeConfiguration implements GeyserConfiguration {
|
||||
return node.getNode("address").getString("127.0.0.1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAddress(String address) {
|
||||
node.getNode("address").setValue(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return node.getNode("port").getInt(25565);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPort(int port) {
|
||||
node.getNode("port").setValue(port);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthType() {
|
||||
return node.getNode("auth-type").getString("online");
|
||||
|
@ -58,6 +58,8 @@ import org.geysermc.connector.utils.DockerCheck;
|
||||
import org.geysermc.connector.utils.LanguageUtils;
|
||||
import org.geysermc.connector.utils.LocaleUtils;
|
||||
|
||||
import javax.naming.directory.Attribute;
|
||||
import javax.naming.directory.InitialDirContext;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
@ -77,6 +79,8 @@ public class GeyserConnector {
|
||||
public static final String NAME = "Geyser";
|
||||
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 static GeyserConnector instance;
|
||||
@ -135,8 +139,30 @@ public class GeyserConnector {
|
||||
if (platformType != PlatformType.STANDALONE) {
|
||||
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());
|
||||
|
||||
if (config.isAboveBedrockNetherBuilding())
|
||||
|
@ -92,6 +92,10 @@ public interface GeyserConfiguration {
|
||||
String getAddress();
|
||||
|
||||
int getPort();
|
||||
|
||||
void setAddress(String address);
|
||||
|
||||
void setPort(int port);
|
||||
|
||||
String getAuthType();
|
||||
}
|
||||
|
@ -59,7 +59,12 @@ public class WolfEntity extends TameableEntity {
|
||||
if (entityMetadata.getId() == 19 && !metadata.getFlags().getFlag(EntityFlag.ANGRY)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -135,12 +135,15 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
|
||||
}
|
||||
break;
|
||||
case OPEN_INVENTORY:
|
||||
ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket();
|
||||
containerOpenPacket.setId((byte) 0);
|
||||
containerOpenPacket.setType(ContainerType.INVENTORY);
|
||||
containerOpenPacket.setUniqueEntityId(-1);
|
||||
containerOpenPacket.setBlockPosition(entity.getPosition().toInt());
|
||||
session.sendUpstreamPacket(containerOpenPacket);
|
||||
if (!session.getInventory().isOpen()) {
|
||||
ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket();
|
||||
containerOpenPacket.setId((byte) 0);
|
||||
containerOpenPacket.setType(ContainerType.INVENTORY);
|
||||
containerOpenPacket.setUniqueEntityId(-1);
|
||||
containerOpenPacket.setBlockPosition(entity.getPosition().toInt());
|
||||
session.sendUpstreamPacket(containerOpenPacket);
|
||||
session.getInventory().setOpen(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -60,15 +60,23 @@ public class MerchantInventoryTranslator extends BaseInventoryTranslator {
|
||||
|
||||
@Override
|
||||
public int bedrockSlotToJava(InventoryActionData action) {
|
||||
if (action.getSource().getContainerId() == ContainerId.UI) {
|
||||
switch (action.getSlot()) {
|
||||
case 4:
|
||||
return 0;
|
||||
case 5:
|
||||
return 1;
|
||||
case 50:
|
||||
return 2;
|
||||
}
|
||||
switch (action.getSource().getContainerId()) {
|
||||
case ContainerId.UI:
|
||||
switch (action.getSlot()) {
|
||||
case 4:
|
||||
return 0;
|
||||
case 5:
|
||||
return 1;
|
||||
case 50:
|
||||
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);
|
||||
}
|
||||
@ -109,10 +117,8 @@ public class MerchantInventoryTranslator extends BaseInventoryTranslator {
|
||||
|
||||
@Override
|
||||
public void translateActions(GeyserSession session, Inventory inventory, List<InventoryActionData> actions) {
|
||||
for (InventoryActionData action : actions) {
|
||||
if (action.getSource().getType() == InventorySource.Type.NON_IMPLEMENTED_TODO) {
|
||||
return;
|
||||
}
|
||||
if (actions.stream().anyMatch(a -> a.getSource().getContainerId() == -31)) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.translateActions(session, inventory, actions);
|
||||
|
@ -62,7 +62,7 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator<Serve
|
||||
|
||||
RespawnPacket respawnPacket = new RespawnPacket();
|
||||
respawnPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
respawnPacket.setPosition(pos);
|
||||
respawnPacket.setPosition(entity.getPosition());
|
||||
respawnPacket.setState(RespawnPacket.State.SERVER_READY);
|
||||
session.sendUpstreamPacket(respawnPacket);
|
||||
|
||||
@ -79,7 +79,7 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator<Serve
|
||||
|
||||
MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
|
||||
movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
movePlayerPacket.setPosition(pos);
|
||||
movePlayerPacket.setPosition(entity.getPosition());
|
||||
movePlayerPacket.setRotation(Vector3f.from(packet.getPitch(), packet.getYaw(), 0));
|
||||
movePlayerPacket.setMode(MovePlayerPacket.Mode.RESPAWN); //TODO: PROBABLY RIGHT BUT STILL CHECK
|
||||
|
||||
|
@ -85,6 +85,7 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
|
||||
playerFlags.add(AdventureSetting.MAY_FLY);
|
||||
playerFlags.add(AdventureSetting.NO_CLIP);
|
||||
playerFlags.add(AdventureSetting.FLYING);
|
||||
playerFlags.add(AdventureSetting.WORLD_IMMUTABLE);
|
||||
gameMode = GameMode.CREATIVE; // spectator doesnt exist on bedrock
|
||||
}
|
||||
|
||||
|
@ -79,15 +79,17 @@ public class GeyserLegacyPingPassthrough implements IGeyserPingPassthrough, Runn
|
||||
public void run() {
|
||||
try {
|
||||
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();
|
||||
DataOutputStream handshake = new DataOutputStream(byteArrayStream);
|
||||
handshake.write(0x0);
|
||||
VarInts.writeUnsignedInt(handshake, MinecraftConstants.PROTOCOL_VERSION);
|
||||
VarInts.writeUnsignedInt(handshake, socket.getInetAddress().getHostAddress().length());
|
||||
handshake.writeBytes(socket.getInetAddress().getHostAddress());
|
||||
handshake.writeShort(socket.getPort());
|
||||
VarInts.writeUnsignedInt(handshake, address.length());
|
||||
handshake.writeBytes(address);
|
||||
handshake.writeShort(port);
|
||||
VarInts.writeUnsignedInt(handshake, 1);
|
||||
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());
|
||||
|
@ -56,7 +56,7 @@ public class InventoryUtils {
|
||||
translator.prepareInventory(session, inventory);
|
||||
//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
|
||||
long delay = 500 - (System.currentTimeMillis() - session.getLastWindowCloseTime());
|
||||
long delay = 700 - (System.currentTimeMillis() - session.getLastWindowCloseTime());
|
||||
//TODO: find better way to handle double chest delay
|
||||
if (translator instanceof DoubleChestInventoryTranslator) {
|
||||
delay = Math.max(delay, 200);
|
||||
@ -87,6 +87,7 @@ public class InventoryUtils {
|
||||
}
|
||||
} else {
|
||||
Inventory inventory = session.getInventory();
|
||||
inventory.setOpen(false);
|
||||
InventoryTranslator translator = InventoryTranslator.INVENTORY_TRANSLATORS.get(inventory.getWindowType());
|
||||
translator.updateInventory(session, inventory);
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 8a62f3730bd1ae94262315ad1535b5d5523de189
|
||||
Subproject commit cd57d6029186293b3ca282243a90252db434714b
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren