Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-24 23:30:22 +01:00
Merge branch 'master' of https://github.com/GeyserMC/Geyser into server-inventory
Dieser Commit ist enthalten in:
Commit
85b8fe2734
@ -101,7 +101,7 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
|
||||
}
|
||||
}
|
||||
|
||||
if (geyserConfig.getBedrock().isCloneRemotePort()){
|
||||
if (geyserConfig.getBedrock().isCloneRemotePort()) {
|
||||
geyserConfig.getBedrock().setPort(geyserConfig.getRemote().getPort());
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,10 @@
|
||||
</parent>
|
||||
<artifactId>connector</artifactId>
|
||||
|
||||
<properties>
|
||||
<netty.version>4.1.59.Final</netty.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
@ -26,14 +30,13 @@
|
||||
<dependency>
|
||||
<groupId>com.github.CloudburstMC.Protocol</groupId>
|
||||
<artifactId>bedrock-v422</artifactId>
|
||||
<version>89617b7689</version>
|
||||
<version>294e7e5</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>net.sf.trove4j</groupId>
|
||||
<artifactId>trove</artifactId>
|
||||
</exclusion>
|
||||
<!-- Stay on the older version of Network while it's rewritten -->
|
||||
<exclusion>
|
||||
<groupId>com.nukkitx.network</groupId>
|
||||
<artifactId>raknet</artifactId>
|
||||
@ -41,10 +44,16 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nukkitx.network</groupId>
|
||||
<groupId>com.github.CloudburstMC.Network</groupId>
|
||||
<artifactId>raknet</artifactId>
|
||||
<version>1.6.20</version>
|
||||
<version>a94d2dd</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nukkitx.fastutil</groupId>
|
||||
@ -147,15 +156,51 @@
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-resolver-dns</artifactId>
|
||||
<version>4.1.43.Final</version>
|
||||
<version>${netty.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-resolver-dns-native-macos</artifactId>
|
||||
<version>${netty.version}</version>
|
||||
<scope>compile</scope>
|
||||
<classifier>osx-x86_64</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-codec-haproxy</artifactId>
|
||||
<version>4.1.56.Final</version>
|
||||
<version>${netty.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- Network dependencies we are updating ourselves -->
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-handler</artifactId>
|
||||
<version>${netty.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-transport-native-epoll</artifactId>
|
||||
<version>${netty.version}</version>
|
||||
<scope>compile</scope>
|
||||
<classifier>linux-x86_64</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-transport-native-epoll</artifactId>
|
||||
<version>${netty.version}</version>
|
||||
<scope>compile</scope>
|
||||
<classifier>linux-aarch_64</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-transport-native-kqueue</artifactId>
|
||||
<version>${netty.version}</version>
|
||||
<scope>compile</scope>
|
||||
<classifier>osx-x86_64</classifier>
|
||||
</dependency>
|
||||
<!-- End -->
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
|
@ -29,6 +29,7 @@ import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nukkitx.network.raknet.RakNetConstants;
|
||||
import com.nukkitx.network.util.EventLoops;
|
||||
import com.nukkitx.protocol.bedrock.BedrockServer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@ -196,7 +197,13 @@ public class GeyserConnector {
|
||||
RakNetConstants.MAXIMUM_MTU_SIZE = (short) config.getMtu();
|
||||
logger.debug("Setting MTU to " + config.getMtu());
|
||||
|
||||
bedrockServer = new BedrockServer(new InetSocketAddress(config.getBedrock().getAddress(), config.getBedrock().getPort()));
|
||||
boolean enableProxyProtocol = config.getBedrock().isEnableProxyProtocol();
|
||||
bedrockServer = new BedrockServer(
|
||||
new InetSocketAddress(config.getBedrock().getAddress(), config.getBedrock().getPort()),
|
||||
1,
|
||||
EventLoops.commonGroup(),
|
||||
enableProxyProtocol
|
||||
);
|
||||
bedrockServer.setHandler(new ConnectorServerEventHandler(this));
|
||||
bedrockServer.bind().whenComplete((avoid, throwable) -> {
|
||||
if (throwable == null) {
|
||||
|
@ -27,9 +27,11 @@ package org.geysermc.connector.configuration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.geysermc.connector.GeyserLogger;
|
||||
import org.geysermc.connector.network.CIDRMatcher;
|
||||
import org.geysermc.connector.utils.LanguageUtils;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface GeyserConfiguration {
|
||||
@ -106,6 +108,15 @@ public interface GeyserConfiguration {
|
||||
String getMotd2();
|
||||
|
||||
String getServerName();
|
||||
|
||||
boolean isEnableProxyProtocol();
|
||||
|
||||
List<String> getProxyProtocolWhitelistedIPs();
|
||||
|
||||
/**
|
||||
* @return Unmodifiable list of {@link CIDRMatcher}s from {@link #getProxyProtocolWhitelistedIPs()}
|
||||
*/
|
||||
List<CIDRMatcher> getWhitelistedIPsMatchers();
|
||||
}
|
||||
|
||||
interface IRemoteConfiguration {
|
||||
|
@ -25,16 +25,21 @@
|
||||
|
||||
package org.geysermc.connector.configuration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.common.serializer.AsteriskSerializer;
|
||||
import org.geysermc.connector.network.CIDRMatcher;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@ -122,6 +127,7 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
|
||||
private MetricsInfo metrics = new MetricsInfo();
|
||||
|
||||
@Getter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class BedrockConfiguration implements IBedrockConfiguration {
|
||||
@AsteriskSerializer.Asterisk(sensitive = true)
|
||||
private String address = "0.0.0.0";
|
||||
@ -137,9 +143,33 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
|
||||
|
||||
@JsonProperty("server-name")
|
||||
private String serverName = GeyserConnector.NAME;
|
||||
|
||||
@JsonProperty("enable-proxy-protocol")
|
||||
private boolean enableProxyProtocol = false;
|
||||
|
||||
@JsonProperty("proxy-protocol-whitelisted-ips")
|
||||
private List<String> proxyProtocolWhitelistedIPs = Collections.emptyList();
|
||||
|
||||
@JsonIgnore
|
||||
private List<CIDRMatcher> whitelistedIPsMatchers = null;
|
||||
|
||||
@Override
|
||||
public List<CIDRMatcher> getWhitelistedIPsMatchers() {
|
||||
// Effective Java, Third Edition; Item 83: Use lazy initialization judiciously
|
||||
List<CIDRMatcher> matchers = this.whitelistedIPsMatchers;
|
||||
if (matchers == null) {
|
||||
synchronized (this) {
|
||||
this.whitelistedIPsMatchers = matchers = proxyProtocolWhitelistedIPs.stream()
|
||||
.map(CIDRMatcher::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableList(matchers);
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class RemoteConfiguration implements IRemoteConfiguration {
|
||||
@Setter
|
||||
@AsteriskSerializer.Asterisk(sensitive = true)
|
||||
@ -173,6 +203,7 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
|
||||
}
|
||||
|
||||
@Getter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class MetricsInfo implements IMetricsInfo {
|
||||
private boolean enabled = true;
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class RabbitEntity extends AnimalEntity {
|
||||
if (entityMetadata.getId() == 15) {
|
||||
metadata.put(EntityData.SCALE, .55f);
|
||||
boolean isBaby = (boolean) entityMetadata.getValue();
|
||||
if(isBaby) {
|
||||
if (isBaby) {
|
||||
metadata.put(EntityData.SCALE, .35f);
|
||||
metadata.getFlags().setFlag(EntityFlag.BABY, true);
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public class VillagerEntity extends AbstractMerchantEntity {
|
||||
Pattern r = Pattern.compile("facing=([a-z]+)");
|
||||
Matcher m = r.matcher(bedRotationZ);
|
||||
if (m.find()) {
|
||||
switch (m.group(0)){
|
||||
switch (m.group(0)) {
|
||||
case "facing=south":
|
||||
//bed is facing south
|
||||
z = 180;
|
||||
|
@ -30,8 +30,11 @@ import org.geysermc.connector.entity.*;
|
||||
import org.geysermc.connector.entity.living.*;
|
||||
import org.geysermc.connector.entity.living.animal.*;
|
||||
import org.geysermc.connector.entity.living.animal.horse.*;
|
||||
import org.geysermc.connector.entity.living.animal.tameable.*;
|
||||
import org.geysermc.connector.entity.living.merchant.*;
|
||||
import org.geysermc.connector.entity.living.animal.tameable.CatEntity;
|
||||
import org.geysermc.connector.entity.living.animal.tameable.ParrotEntity;
|
||||
import org.geysermc.connector.entity.living.animal.tameable.WolfEntity;
|
||||
import org.geysermc.connector.entity.living.merchant.AbstractMerchantEntity;
|
||||
import org.geysermc.connector.entity.living.merchant.VillagerEntity;
|
||||
import org.geysermc.connector.entity.living.monster.*;
|
||||
import org.geysermc.connector.entity.living.monster.raid.AbstractIllagerEntity;
|
||||
import org.geysermc.connector.entity.living.monster.raid.PillagerEntity;
|
||||
@ -39,6 +42,9 @@ import org.geysermc.connector.entity.living.monster.raid.RaidParticipantEntity;
|
||||
import org.geysermc.connector.entity.living.monster.raid.SpellcasterIllagerEntity;
|
||||
import org.geysermc.connector.entity.player.PlayerEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public enum EntityType {
|
||||
|
||||
@ -174,17 +180,33 @@ public enum EntityType {
|
||||
*/
|
||||
ENDER_DRAGON_PART(EnderDragonPartEntity.class, 32, 0, 0, 0, 0, "minecraft:armor_stand");
|
||||
|
||||
/**
|
||||
* A list of all Java identifiers for use with command suggestions
|
||||
*/
|
||||
public static final String[] ALL_JAVA_IDENTIFIERS;
|
||||
private static final EntityType[] VALUES = values();
|
||||
|
||||
private Class<? extends Entity> entityClass;
|
||||
static {
|
||||
List<String> allJavaIdentifiers = new ArrayList<>();
|
||||
for (EntityType type : values()) {
|
||||
if (type == AGENT || type == BALLOON || type == CHALKBOARD || type == NPC || type == TRIPOD_CAMERA || type == ENDER_DRAGON_PART) {
|
||||
continue;
|
||||
}
|
||||
allJavaIdentifiers.add("minecraft:" + type.name().toLowerCase());
|
||||
}
|
||||
ALL_JAVA_IDENTIFIERS = allJavaIdentifiers.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private final Class<? extends Entity> entityClass;
|
||||
private final int type;
|
||||
private final float height;
|
||||
private final float width;
|
||||
private final float length;
|
||||
private final float offset;
|
||||
private String identifier;
|
||||
private final String identifier;
|
||||
|
||||
EntityType(Class<? extends Entity> entityClass, int type, float height) {
|
||||
//noinspection SuspiciousNameCombination
|
||||
this(entityClass, type, height, height);
|
||||
}
|
||||
|
||||
@ -198,8 +220,6 @@ public enum EntityType {
|
||||
|
||||
EntityType(Class<? extends Entity> entityClass, int type, float height, float width, float length, float offset) {
|
||||
this(entityClass, type, height, width, length, offset, null);
|
||||
|
||||
this.identifier = "minecraft:" + name().toLowerCase();
|
||||
}
|
||||
|
||||
EntityType(Class<? extends Entity> entityClass, int type, float height, float width, float length, float offset, String identifier) {
|
||||
@ -209,7 +229,7 @@ public enum EntityType {
|
||||
this.width = width;
|
||||
this.length = length;
|
||||
this.offset = offset + 0.00001f;
|
||||
this.identifier = identifier;
|
||||
this.identifier = identifier == null ? "minecraft:" + name().toLowerCase() : identifier;
|
||||
}
|
||||
|
||||
public static EntityType getFromIdentifier(String identifier) {
|
||||
|
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.connector.network;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/*
|
||||
* Taken & modified from TCPShield, licensed under MIT. See https://github.com/TCPShield/RealIP/blob/master/LICENSE
|
||||
*
|
||||
* https://github.com/TCPShield/RealIP/blob/32d422a9523cb6e25b571072851f3306bb8bbc4f/src/main/java/net/tcpshield/tcpshield/validation/cidr/CIDRMatcher.java
|
||||
*/
|
||||
public class CIDRMatcher {
|
||||
private final int maskBits;
|
||||
private final int maskBytes;
|
||||
private final boolean simpleCIDR;
|
||||
private final InetAddress cidrAddress;
|
||||
|
||||
public CIDRMatcher(String ipAddress) {
|
||||
String[] split = ipAddress.split("/", 2);
|
||||
|
||||
String parsedIPAddress;
|
||||
if (split.length == 2) {
|
||||
parsedIPAddress = split[0];
|
||||
|
||||
this.maskBits = Integer.parseInt(split[1]);
|
||||
this.simpleCIDR = maskBits == 32;
|
||||
} else {
|
||||
parsedIPAddress = ipAddress;
|
||||
|
||||
this.maskBits = -1;
|
||||
this.simpleCIDR = true;
|
||||
}
|
||||
|
||||
this.maskBytes = simpleCIDR ? -1 : maskBits / 8;
|
||||
|
||||
try {
|
||||
cidrAddress = InetAddress.getByName(parsedIPAddress);
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean matches(InetAddress inetAddress) {
|
||||
// check if IP is IPv4 or IPv6
|
||||
if (cidrAddress.getClass() != inetAddress.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check for equality if it's a simple CIDR
|
||||
if (simpleCIDR) {
|
||||
return inetAddress.equals(cidrAddress);
|
||||
}
|
||||
|
||||
byte[] inetAddressBytes = inetAddress.getAddress();
|
||||
byte[] requiredAddressBytes = cidrAddress.getAddress();
|
||||
|
||||
byte finalByte = (byte) (0xFF00 >> (maskBits & 0x07));
|
||||
|
||||
for (int i = 0; i < maskBytes; i++) {
|
||||
if (inetAddressBytes[i] != requiredAddressBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (finalByte != 0) {
|
||||
return (inetAddressBytes[maskBytes] & finalByte) == (requiredAddressBytes[maskBytes] & finalByte);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -40,6 +40,7 @@ import org.geysermc.connector.utils.LanguageUtils;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
public class ConnectorServerEventHandler implements BedrockServerEventHandler {
|
||||
/*
|
||||
@ -60,6 +61,21 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
|
||||
|
||||
@Override
|
||||
public boolean onConnectionRequest(InetSocketAddress inetSocketAddress) {
|
||||
List<String> allowedProxyIPs = connector.getConfig().getBedrock().getProxyProtocolWhitelistedIPs();
|
||||
if (connector.getConfig().getBedrock().isEnableProxyProtocol() && !allowedProxyIPs.isEmpty()) {
|
||||
boolean isWhitelistedIP = false;
|
||||
for (CIDRMatcher matcher : connector.getConfig().getBedrock().getWhitelistedIPsMatchers()) {
|
||||
if (matcher.matches(inetSocketAddress.getAddress())) {
|
||||
isWhitelistedIP = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isWhitelistedIP) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.network.attempt_connect", inetSocketAddress));
|
||||
return true;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class QueryPacketHandler {
|
||||
* @param buffer The Query data
|
||||
*/
|
||||
public QueryPacketHandler(GeyserConnector connector, InetSocketAddress sender, ByteBuf buffer) {
|
||||
if(!isQueryPacket(buffer))
|
||||
if (!isQueryPacket(buffer))
|
||||
return;
|
||||
|
||||
this.connector = connector;
|
||||
@ -225,7 +225,7 @@ public class QueryPacketHandler {
|
||||
query.write(new byte[] { 0x00, 0x00 });
|
||||
|
||||
// Fill player names
|
||||
if(pingInfo != null) {
|
||||
if (pingInfo != null) {
|
||||
for (String username : pingInfo.getPlayerList()) {
|
||||
query.write(username.getBytes());
|
||||
query.write((byte) 0x00);
|
||||
|
@ -97,6 +97,7 @@ import org.geysermc.floodgate.util.BedrockData;
|
||||
import org.geysermc.floodgate.util.EncryptionUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.PublicKey;
|
||||
@ -427,7 +428,8 @@ public class GeyserSession implements CommandSender {
|
||||
tmpPlayers.forEach(player -> this.emotes.addAll(player.getEmotes()));
|
||||
|
||||
bedrockServerSession.addDisconnectHandler(disconnectReason -> {
|
||||
connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.network.disconnect", bedrockServerSession.getAddress().getAddress(), disconnectReason));
|
||||
InetAddress address = bedrockServerSession.getRealAddress().getAddress();
|
||||
connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.network.disconnect", address, disconnectReason));
|
||||
|
||||
disconnect(disconnectReason.name());
|
||||
connector.removePlayer(this);
|
||||
@ -637,7 +639,7 @@ public class GeyserSession implements CommandSender {
|
||||
clientData.getDeviceOS().ordinal(),
|
||||
clientData.getLanguageCode(),
|
||||
clientData.getCurrentInputMode().ordinal(),
|
||||
upstream.getSession().getAddress().getAddress().getHostAddress()
|
||||
upstream.getAddress().getAddress().getHostAddress()
|
||||
));
|
||||
} catch (Exception e) {
|
||||
connector.getLogger().error(LanguageUtils.getLocaleStringLog("geyser.auth.floodgate.encrypt_fail"), e);
|
||||
@ -888,7 +890,14 @@ public class GeyserSession implements CommandSender {
|
||||
startGamePacket.setItemEntries(ItemRegistry.ITEMS);
|
||||
startGamePacket.setVanillaVersion("*");
|
||||
startGamePacket.setInventoriesServerAuthoritative(true);
|
||||
startGamePacket.setAuthoritativeMovementMode(AuthoritativeMovementMode.CLIENT);
|
||||
startGamePacket.setAuthoritativeMovementMode(AuthoritativeMovementMode.CLIENT); // can be removed once 1.16.200 support is dropped
|
||||
|
||||
SyncedPlayerMovementSettings settings = new SyncedPlayerMovementSettings();
|
||||
settings.setMovementMode(AuthoritativeMovementMode.CLIENT);
|
||||
settings.setRewindHistorySize(0);
|
||||
settings.setServerAuthoritativeBlockBreaking(false);
|
||||
startGamePacket.setPlayerMovementSettings(settings);
|
||||
|
||||
upstream.sendPacket(startGamePacket);
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,6 @@ public class UpstreamSession {
|
||||
}
|
||||
|
||||
public InetSocketAddress getAddress() {
|
||||
return session.getAddress();
|
||||
return session.getRealAddress();
|
||||
}
|
||||
}
|
||||
|
@ -103,6 +103,8 @@ public class BedrockClientData {
|
||||
private String skinColor;
|
||||
@JsonProperty(value = "ThirdPartyNameOnly")
|
||||
private boolean thirdPartyNameOnly;
|
||||
@JsonProperty(value = "PlayFabId")
|
||||
private String playFabId;
|
||||
|
||||
public enum UIProfile {
|
||||
@JsonEnumDefaultValue
|
||||
|
@ -36,6 +36,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlaye
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||
import com.nukkitx.protocol.bedrock.data.PlayerActionType;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
||||
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
||||
@ -63,7 +64,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
||||
return;
|
||||
|
||||
// Send book update before any player action
|
||||
if (packet.getAction() != PlayerActionPacket.Action.RESPAWN) {
|
||||
if (packet.getAction() != PlayerActionType.RESPAWN) {
|
||||
session.getBookEditCache().checkForSend();
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,18 @@ public enum Enchantment {
|
||||
QUICK_CHARGE,
|
||||
SOUL_SPEED;
|
||||
|
||||
/**
|
||||
* A list of all enchantment Java identifiers for use with command suggestions.
|
||||
*/
|
||||
public static final String[] ALL_JAVA_IDENTIFIERS;
|
||||
|
||||
static {
|
||||
ALL_JAVA_IDENTIFIERS = new String[values().length];
|
||||
for (int i = 0; i < ALL_JAVA_IDENTIFIERS.length; i++) {
|
||||
ALL_JAVA_IDENTIFIERS[i] = values()[i].javaIdentifier;
|
||||
}
|
||||
}
|
||||
|
||||
private final String javaIdentifier;
|
||||
|
||||
Enchantment() {
|
||||
|
@ -63,6 +63,11 @@ public class ItemRegistry {
|
||||
public static final List<StartGamePacket.ItemEntry> ITEMS = new ArrayList<>();
|
||||
public static final Int2ObjectMap<ItemEntry> ITEM_ENTRIES = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
/**
|
||||
* A list of all Java item names.
|
||||
*/
|
||||
public static final String[] ITEM_NAMES;
|
||||
|
||||
/**
|
||||
* Bamboo item entry, used in PandaEntity.java
|
||||
*/
|
||||
@ -116,6 +121,8 @@ public class ItemRegistry {
|
||||
// Used to get the Bedrock namespaced ID (in instances where there are small differences)
|
||||
Int2ObjectMap<String> bedrockIdToIdentifier = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
List<String> itemNames = new ArrayList<>();
|
||||
|
||||
List<JsonNode> itemEntries;
|
||||
try {
|
||||
itemEntries = GeyserConnector.JSON_MAPPER.readValue(stream, itemEntriesType);
|
||||
@ -212,6 +219,8 @@ public class ItemRegistry {
|
||||
BUCKETS.add(entry.getValue().get("bedrock_id").intValue());
|
||||
}
|
||||
|
||||
itemNames.add(entry.getKey());
|
||||
|
||||
itemIndex++;
|
||||
}
|
||||
|
||||
@ -240,6 +249,8 @@ public class ItemRegistry {
|
||||
creativeItems.add(ItemData.fromNet(netId++, item.getId(), item.getDamage(), item.getCount(), item.getTag()));
|
||||
}
|
||||
CREATIVE_ITEMS = creativeItems.toArray(new ItemData[0]);
|
||||
|
||||
ITEM_NAMES = itemNames.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,21 +33,69 @@ import com.nukkitx.protocol.bedrock.data.command.CommandEnumData;
|
||||
import com.nukkitx.protocol.bedrock.data.command.CommandParamData;
|
||||
import com.nukkitx.protocol.bedrock.data.command.CommandParamType;
|
||||
import com.nukkitx.protocol.bedrock.packet.AvailableCommandsPacket;
|
||||
import it.unimi.dsi.fastutil.Hash;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.entity.type.EntityType;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.network.translators.item.Enchantment;
|
||||
import org.geysermc.connector.network.translators.item.ItemRegistry;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
@Translator(packet = ServerDeclareCommandsPacket.class)
|
||||
public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclareCommandsPacket> {
|
||||
|
||||
private static final String[] ENUM_BOOLEAN = {"true", "false"};
|
||||
private static final String[] VALID_COLORS;
|
||||
private static final String[] VALID_SCOREBOARD_SLOTS;
|
||||
|
||||
private static final Hash.Strategy<CommandParamData[][]> PARAM_STRATEGY = new Hash.Strategy<CommandParamData[][]>() {
|
||||
@Override
|
||||
public int hashCode(CommandParamData[][] o) {
|
||||
return Arrays.deepHashCode(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(CommandParamData[][] a, CommandParamData[][] b) {
|
||||
if (a == b) return true;
|
||||
if (a == null || b == null) return false;
|
||||
if (a.length != b.length) return false;
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
CommandParamData[] a1 = a[i];
|
||||
CommandParamData[] b1 = b[i];
|
||||
if (a1.length != b1.length) return false;
|
||||
|
||||
for (int j = 0; j < a1.length; j++) {
|
||||
if (!a1[j].equals(b1[j])) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static {
|
||||
List<String> validColors = new ArrayList<>(NamedTextColor.NAMES.keys());
|
||||
validColors.add("reset");
|
||||
VALID_COLORS = validColors.toArray(new String[0]);
|
||||
|
||||
List<String> teamOptions = new ArrayList<>(Arrays.asList("list", "sidebar", "belowName"));
|
||||
for (String color : NamedTextColor.NAMES.keys()) {
|
||||
teamOptions.add("sidebar.team." + color);
|
||||
}
|
||||
VALID_SCOREBOARD_SLOTS = teamOptions.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(ServerDeclareCommandsPacket packet, GeyserSession session) {
|
||||
// Don't send command suggestions if they are disabled
|
||||
@ -60,48 +108,50 @@ public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclar
|
||||
return;
|
||||
}
|
||||
|
||||
CommandNode[] nodes = packet.getNodes();
|
||||
List<CommandData> commandData = new ArrayList<>();
|
||||
Int2ObjectMap<String> commands = new Int2ObjectOpenHashMap<>();
|
||||
IntSet commandNodes = new IntOpenHashSet();
|
||||
Set<String> knownAliases = new HashSet<>();
|
||||
Map<CommandParamData[][], Set<String>> commands = new Object2ObjectOpenCustomHashMap<>(PARAM_STRATEGY);
|
||||
Int2ObjectMap<List<CommandNode>> commandArgs = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
// Get the first node, it should be a root node
|
||||
CommandNode rootNode = packet.getNodes()[packet.getFirstNodeIndex()];
|
||||
CommandNode rootNode = nodes[packet.getFirstNodeIndex()];
|
||||
|
||||
// Loop through the root nodes to get all commands
|
||||
for (int nodeIndex : rootNode.getChildIndices()) {
|
||||
CommandNode node = packet.getNodes()[nodeIndex];
|
||||
CommandNode node = nodes[nodeIndex];
|
||||
|
||||
// Make sure we don't have duplicated commands (happens if there is more than 1 root node)
|
||||
if (commands.containsKey(nodeIndex)) { continue; }
|
||||
if (commands.containsValue(node.getName())) { continue; }
|
||||
if (!commandNodes.add(nodeIndex) || !knownAliases.add(node.getName().toLowerCase())) continue;
|
||||
|
||||
// Get and update the commandArgs list with the found arguments
|
||||
if (node.getChildIndices().length >= 1) {
|
||||
for (int childIndex : node.getChildIndices()) {
|
||||
commandArgs.putIfAbsent(nodeIndex, new ArrayList<>());
|
||||
commandArgs.get(nodeIndex).add(packet.getNodes()[childIndex]);
|
||||
commandArgs.computeIfAbsent(nodeIndex, ArrayList::new).add(nodes[childIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
// Insert the command name into the list
|
||||
commands.put(nodeIndex, node.getName());
|
||||
// Get and parse all params
|
||||
CommandParamData[][] params = getParams(nodes[nodeIndex], nodes);
|
||||
|
||||
// Insert the alias name into the command list
|
||||
commands.computeIfAbsent(params, index -> new HashSet<>()).add(node.getName().toLowerCase());
|
||||
}
|
||||
|
||||
// The command flags, not sure what these do apart from break things
|
||||
List<CommandData.Flag> flags = Collections.emptyList();
|
||||
|
||||
// Loop through all the found commands
|
||||
for (int commandID : commands.keySet()) {
|
||||
String commandName = commands.get(commandID);
|
||||
|
||||
for (Map.Entry<CommandParamData[][], Set<String>> entry : commands.entrySet()) {
|
||||
String commandName = entry.getValue().iterator().next(); // We know this has a value
|
||||
|
||||
// Create a basic alias
|
||||
CommandEnumData aliases = new CommandEnumData(commandName + "Aliases", new String[] { commandName.toLowerCase() }, false);
|
||||
|
||||
// Get and parse all params
|
||||
CommandParamData[][] params = getParams(packet.getNodes()[commandID], packet.getNodes());
|
||||
CommandEnumData aliases = new CommandEnumData(commandName + "Aliases", entry.getValue().toArray(new String[0]), false);
|
||||
|
||||
// Build the completed command and add it to the final list
|
||||
CommandData data = new CommandData(commandName, session.getConnector().getCommandManager().getDescription(commandName), flags, (byte) 0, aliases, params);
|
||||
CommandData data = new CommandData(commandName, session.getConnector().getCommandManager().getDescription(commandName), flags, (byte) 0, aliases, entry.getKey());
|
||||
commandData.add(data);
|
||||
}
|
||||
|
||||
@ -109,7 +159,7 @@ public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclar
|
||||
AvailableCommandsPacket availableCommandsPacket = new AvailableCommandsPacket();
|
||||
availableCommandsPacket.getCommands().addAll(commandData);
|
||||
|
||||
GeyserConnector.getInstance().getLogger().debug("Sending command packet of " + commandData.size() + " commands");
|
||||
session.getConnector().getLogger().debug("Sending command packet of " + commandData.size() + " commands");
|
||||
|
||||
// Finally, send the commands to the client
|
||||
session.sendUpstreamPacket(availableCommandsPacket);
|
||||
@ -119,11 +169,10 @@ public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclar
|
||||
* Build the command parameter array for the given command
|
||||
*
|
||||
* @param commandNode The command to build the parameters for
|
||||
* @param allNodes Every command node
|
||||
*
|
||||
* @param allNodes Every command node
|
||||
* @return An array of parameter option arrays
|
||||
*/
|
||||
private CommandParamData[][] getParams(CommandNode commandNode, CommandNode[] allNodes) {
|
||||
private static CommandParamData[][] getParams(CommandNode commandNode, CommandNode[] allNodes) {
|
||||
// Check if the command is an alias and redirect it
|
||||
if (commandNode.getRedirectIndex() != -1) {
|
||||
GeyserConnector.getInstance().getLogger().debug("Redirecting command " + commandNode.getName() + " to " + allNodes[commandNode.getRedirectIndex()].getName());
|
||||
@ -136,16 +185,8 @@ public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclar
|
||||
rootParam.buildChildren(allNodes);
|
||||
|
||||
List<CommandParamData[]> treeData = rootParam.getTree();
|
||||
CommandParamData[][] params = new CommandParamData[treeData.size()][];
|
||||
|
||||
// Fill the nested params array
|
||||
int i = 0;
|
||||
for (CommandParamData[] tree : treeData) {
|
||||
params[i] = tree;
|
||||
i++;
|
||||
}
|
||||
|
||||
return params;
|
||||
return treeData.toArray(new CommandParamData[0][]);
|
||||
}
|
||||
|
||||
return new CommandParamData[0][0];
|
||||
@ -155,14 +196,17 @@ public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclar
|
||||
* Convert Java edition command types to Bedrock edition
|
||||
*
|
||||
* @param parser Command type to convert
|
||||
*
|
||||
* @return Bedrock parameter data type
|
||||
*/
|
||||
private CommandParamType mapCommandType(CommandParser parser) {
|
||||
if (parser == null) { return CommandParamType.STRING; }
|
||||
private static Object mapCommandType(CommandParser parser) {
|
||||
if (parser == null) {
|
||||
return CommandParamType.STRING;
|
||||
}
|
||||
|
||||
switch (parser) {
|
||||
case FLOAT:
|
||||
case ROTATION:
|
||||
case DOUBLE:
|
||||
return CommandParamType.FLOAT;
|
||||
|
||||
case INTEGER:
|
||||
@ -189,50 +233,44 @@ public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclar
|
||||
return CommandParamType.JSON;
|
||||
|
||||
case RESOURCE_LOCATION:
|
||||
case FUNCTION:
|
||||
return CommandParamType.FILE_PATH;
|
||||
|
||||
case INT_RANGE:
|
||||
return CommandParamType.INT_RANGE;
|
||||
|
||||
case BOOL:
|
||||
case DOUBLE:
|
||||
case STRING:
|
||||
case VEC2:
|
||||
return ENUM_BOOLEAN;
|
||||
|
||||
case OPERATION: // ">=", "==", etc
|
||||
return CommandParamType.OPERATOR;
|
||||
|
||||
case BLOCK_STATE:
|
||||
case BLOCK_PREDICATE:
|
||||
return BlockTranslator.getAllBlockIdentifiers();
|
||||
|
||||
case ITEM_STACK:
|
||||
case ITEM_PREDICATE:
|
||||
case COLOR:
|
||||
case COMPONENT:
|
||||
case OBJECTIVE:
|
||||
case OBJECTIVE_CRITERIA:
|
||||
case OPERATION: // Possibly OPERATOR
|
||||
case PARTICLE:
|
||||
case ROTATION:
|
||||
case SCOREBOARD_SLOT:
|
||||
case SCORE_HOLDER:
|
||||
case SWIZZLE:
|
||||
case TEAM:
|
||||
case ITEM_SLOT:
|
||||
case MOB_EFFECT:
|
||||
case FUNCTION:
|
||||
case ENTITY_ANCHOR:
|
||||
case RANGE:
|
||||
case FLOAT_RANGE:
|
||||
return ItemRegistry.ITEM_NAMES;
|
||||
|
||||
case ITEM_ENCHANTMENT:
|
||||
return Enchantment.ALL_JAVA_IDENTIFIERS; //TODO: inventory branch use Java enums
|
||||
|
||||
case ENTITY_SUMMON:
|
||||
case DIMENSION:
|
||||
case TIME:
|
||||
return EntityType.ALL_JAVA_IDENTIFIERS;
|
||||
|
||||
case COLOR:
|
||||
return VALID_COLORS;
|
||||
|
||||
case SCOREBOARD_SLOT:
|
||||
return VALID_SCOREBOARD_SLOTS;
|
||||
|
||||
default:
|
||||
return CommandParamType.STRING;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
private class ParamInfo {
|
||||
private CommandNode paramNode;
|
||||
private CommandParamData paramData;
|
||||
private List<ParamInfo> children;
|
||||
@ToString
|
||||
private static class ParamInfo {
|
||||
private final CommandNode paramNode;
|
||||
private final CommandParamData paramData;
|
||||
private final List<ParamInfo> children;
|
||||
|
||||
/**
|
||||
* Create a new parameter info object
|
||||
@ -252,33 +290,50 @@ public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclar
|
||||
* @param allNodes Every command node
|
||||
*/
|
||||
public void buildChildren(CommandNode[] allNodes) {
|
||||
int enumIndex = -1;
|
||||
|
||||
for (int paramID : paramNode.getChildIndices()) {
|
||||
CommandNode paramNode = allNodes[paramID];
|
||||
|
||||
if (paramNode.getParser() == null) {
|
||||
if (enumIndex == -1) {
|
||||
enumIndex = children.size();
|
||||
boolean foundCompatible = false;
|
||||
for (int i = 0; i < children.size(); i++) {
|
||||
ParamInfo enumParamInfo = children.get(i);
|
||||
// Check to make sure all descending nodes of this command are compatible - otherwise, create a new overload
|
||||
if (isCompatible(allNodes, enumParamInfo.getParamNode(), paramNode)) {
|
||||
foundCompatible = true;
|
||||
// Extend the current list of enum values
|
||||
String[] enumOptions = Arrays.copyOf(enumParamInfo.getParamData().getEnumData().getValues(), enumParamInfo.getParamData().getEnumData().getValues().length + 1);
|
||||
enumOptions[enumOptions.length - 1] = paramNode.getName();
|
||||
|
||||
// Create the new enum command
|
||||
CommandEnumData enumData = new CommandEnumData(paramNode.getName(), new String[] { paramNode.getName() }, false);
|
||||
children.add(new ParamInfo(paramNode, new CommandParamData(paramNode.getName(), false, enumData, mapCommandType(paramNode.getParser()), null, Collections.emptyList())));
|
||||
} else {
|
||||
// Get the existing enum
|
||||
ParamInfo enumParamInfo = children.get(enumIndex);
|
||||
|
||||
// Extend the current list of enum values
|
||||
String[] enumOptions = Arrays.copyOf(enumParamInfo.getParamData().getEnumData().getValues(), enumParamInfo.getParamData().getEnumData().getValues().length + 1);
|
||||
enumOptions[enumOptions.length - 1] = paramNode.getName();
|
||||
|
||||
// Re-create the command using the updated values
|
||||
CommandEnumData enumData = new CommandEnumData(enumParamInfo.getParamData().getEnumData().getName(), enumOptions, false);
|
||||
children.set(enumIndex, new ParamInfo(enumParamInfo.getParamNode(), new CommandParamData(enumParamInfo.getParamData().getName(), false, enumData, enumParamInfo.getParamData().getType(), null, Collections.emptyList())));
|
||||
// Re-create the command using the updated values
|
||||
CommandEnumData enumData = new CommandEnumData(enumParamInfo.getParamData().getEnumData().getName(), enumOptions, false);
|
||||
children.set(i, new ParamInfo(enumParamInfo.getParamNode(), new CommandParamData(enumParamInfo.getParamData().getName(), this.paramNode.isExecutable(), enumData, null, null, Collections.emptyList())));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
if (!foundCompatible) {
|
||||
// Create a new subcommand with this exact type
|
||||
CommandEnumData enumData = new CommandEnumData(paramNode.getName(), new String[]{paramNode.getName()}, false);
|
||||
|
||||
// On setting optional:
|
||||
// isExecutable is defined as a node "constitutes a valid command."
|
||||
// Therefore, any children of the parameter must simply be optional.
|
||||
children.add(new ParamInfo(paramNode, new CommandParamData(paramNode.getName(), this.paramNode.isExecutable(), enumData, null, null, Collections.emptyList())));
|
||||
}
|
||||
} else {
|
||||
// Put the non-enum param into the list
|
||||
children.add(new ParamInfo(paramNode, new CommandParamData(paramNode.getName(), false, null, mapCommandType(paramNode.getParser()), null, Collections.emptyList())));
|
||||
Object mappedType = mapCommandType(paramNode.getParser());
|
||||
CommandEnumData enumData = null;
|
||||
CommandParamType type = null;
|
||||
if (mappedType instanceof String[]) {
|
||||
enumData = new CommandEnumData(paramNode.getParser().name().toLowerCase(), (String[]) mappedType, false);
|
||||
} else {
|
||||
type = (CommandParamType) mappedType;
|
||||
}
|
||||
// IF enumData != null:
|
||||
// In game, this will show up like <paramNode.getName(): enumData.getName()>
|
||||
// So if paramNode.getName() == "value" and enumData.getName() == "bool": <value: bool>
|
||||
children.add(new ParamInfo(paramNode, new CommandParamData(paramNode.getName(), this.paramNode.isExecutable(), enumData, type, null, Collections.emptyList())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -288,6 +343,64 @@ public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclar
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparing CommandNode type a and b, determine if they are in the same overload.
|
||||
* <p>
|
||||
* Take the <code>gamerule</code> command, and let's present three "subcommands" you can perform:
|
||||
*
|
||||
* <ul>
|
||||
* <li><code>gamerule doDaylightCycle true</code></li>
|
||||
* <li><code>gamerule announceAdvancements false</code></li>
|
||||
* <li><code>gamerule randomTickSpeed 3</code></li>
|
||||
* </ul>
|
||||
*
|
||||
* While all three of them are indeed part of the same command, the command setting randomTickSpeed parses an int,
|
||||
* while the others use boolean. In Bedrock, this should be presented as a separate overload to indicate that this
|
||||
* does something a little different.
|
||||
* <p>
|
||||
* Therefore, this function will return <code>true</code> if the first two are compared, as they use the same
|
||||
* parsers. If the third is compared with either of the others, this function will return <code>false</code>.
|
||||
* <p>
|
||||
* Here's an example of how the above would be presented to Bedrock (as of 1.16.200). Notice how the top two <code>CommandParamData</code>
|
||||
* classes of each array are identical in type, but the following class is different:
|
||||
* <pre>
|
||||
* overloads=[
|
||||
* [
|
||||
* CommandParamData(name=doDaylightCycle, optional=false, enumData=CommandEnumData(name=announceAdvancements, values=[announceAdvancements, doDaylightCycle], isSoft=false), type=STRING, postfix=null, options=[])
|
||||
* CommandParamData(name=value, optional=false, enumData=CommandEnumData(name=value, values=[true, false], isSoft=false), type=null, postfix=null, options=[])
|
||||
* ]
|
||||
* [
|
||||
* CommandParamData(name=randomTickSpeed, optional=false, enumData=CommandEnumData(name=randomTickSpeed, values=[randomTickSpeed], isSoft=false), type=STRING, postfix=null, options=[])
|
||||
* CommandParamData(name=value, optional=false, enumData=null, type=INT, postfix=null, options=[])
|
||||
* ]
|
||||
* ]
|
||||
* </pre>
|
||||
*
|
||||
* @return if these two can be merged into one overload.
|
||||
*/
|
||||
private boolean isCompatible(CommandNode[] allNodes, CommandNode a, CommandNode b) {
|
||||
if (a == b) return true;
|
||||
if (a.getParser() != b.getParser()) return false;
|
||||
if (a.getChildIndices().length != b.getChildIndices().length) return false;
|
||||
|
||||
for (int i = 0; i < a.getChildIndices().length; i++) {
|
||||
boolean hasSimilarity = false;
|
||||
CommandNode a1 = allNodes[a.getChildIndices()[i]];
|
||||
// Search "b" until we find a child that matches this one
|
||||
for (int j = 0; j < b.getChildIndices().length; j++) {
|
||||
if (isCompatible(allNodes, a1, allNodes[b.getChildIndices()[j]])) {
|
||||
hasSimilarity = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasSimilarity) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tree of every parameter node (recursive)
|
||||
*
|
||||
@ -301,13 +414,10 @@ public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclar
|
||||
List<CommandParamData[]> childTree = child.getTree();
|
||||
|
||||
// Un-pack the tree append the child node to it and push into the list
|
||||
for (CommandParamData[] subchild : childTree) {
|
||||
CommandParamData[] tmpTree = new ArrayList<CommandParamData>() {
|
||||
{
|
||||
add(child.getParamData());
|
||||
addAll(Arrays.asList(subchild));
|
||||
}
|
||||
}.toArray(new CommandParamData[0]);
|
||||
for (CommandParamData[] subChild : childTree) {
|
||||
CommandParamData[] tmpTree = new CommandParamData[subChild.length + 1];
|
||||
tmpTree[0] = child.getParamData();
|
||||
System.arraycopy(subChild, 0, tmpTree, 1, subChild.length);
|
||||
|
||||
treeParamData.add(tmpTree);
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ public class JavaTitleTranslator extends PacketTranslator<ServerTitlePacket> {
|
||||
titlePacket.setFadeInTime(packet.getFadeIn());
|
||||
titlePacket.setFadeOutTime(packet.getFadeOut());
|
||||
titlePacket.setStayTime(packet.getStay());
|
||||
titlePacket.setText("");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,9 @@ public class JavaEntityAnimationTranslator extends PacketTranslator<ServerEntity
|
||||
case LEAVE_BED:
|
||||
animatePacket.setAction(AnimatePacket.Action.WAKE_UP);
|
||||
break;
|
||||
default:
|
||||
// Unknown Animation
|
||||
return;
|
||||
}
|
||||
|
||||
session.sendUpstreamPacket(animatePacket);
|
||||
|
@ -52,7 +52,7 @@ public class JavaPlaySoundTranslator extends PacketTranslator<ServerPlaySoundPac
|
||||
|
||||
SoundRegistry.SoundMapping soundMapping = SoundRegistry.fromJava(packetSound.replace("minecraft:", ""));
|
||||
String playsound;
|
||||
if(soundMapping == null || soundMapping.getPlaysound() == null) {
|
||||
if (soundMapping == null || soundMapping.getPlaysound() == null) {
|
||||
// no mapping
|
||||
session.getConnector().getLogger()
|
||||
.debug("[PlaySound] Defaulting to sound server gave us for " + packet.toString());
|
||||
|
@ -386,4 +386,11 @@ public class BlockTranslator {
|
||||
}
|
||||
return itemIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of all Java block identifiers. For use with command suggestions.
|
||||
*/
|
||||
public static String[] getAllBlockIdentifiers() {
|
||||
return JAVA_ID_TO_JAVA_IDENTIFIER_MAP.values().toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class SkinManager {
|
||||
String capeId, byte[] capeData,
|
||||
SkinProvider.SkinGeometry geometry) {
|
||||
SerializedSkin serializedSkin = SerializedSkin.of(
|
||||
skinId, geometry.getGeometryName(), ImageData.of(skinData), Collections.emptyList(),
|
||||
skinId, "", geometry.getGeometryName(), ImageData.of(skinData), Collections.emptyList(),
|
||||
ImageData.of(capeData), geometry.getGeometryData(), "", true, false,
|
||||
!capeId.equals(SkinProvider.EMPTY_CAPE.getCapeId()), capeId, skinId
|
||||
);
|
||||
|
@ -42,7 +42,7 @@ public class SkullSkinManager extends SkinManager {
|
||||
// Prevents https://cdn.discordapp.com/attachments/613194828359925800/779458146191147008/unknown.png
|
||||
skinId = skinId + "_skull";
|
||||
return SerializedSkin.of(
|
||||
skinId, SkinProvider.SKULL_GEOMETRY.getGeometryName(), ImageData.of(skinData), Collections.emptyList(),
|
||||
skinId, "", SkinProvider.SKULL_GEOMETRY.getGeometryName(), ImageData.of(skinData), Collections.emptyList(),
|
||||
ImageData.of(SkinProvider.EMPTY_CAPE.getCapeData()), SkinProvider.SKULL_GEOMETRY.getGeometryData(),
|
||||
"", true, false, false, SkinProvider.EMPTY_CAPE.getCapeId(), skinId
|
||||
);
|
||||
|
@ -23,6 +23,14 @@ bedrock:
|
||||
motd2: "Another Geyser server."
|
||||
# The Server Name that will be sent to Minecraft: Bedrock Edition clients. This is visible in both the pause menu and the settings menu.
|
||||
server-name: "Geyser"
|
||||
# Whether to enable PROXY protocol or not for clients. You DO NOT WANT this feature unless you run UDP reverse proxy
|
||||
# in front of your Geyser instance.
|
||||
enable-proxy-protocol: false
|
||||
# A list of allowed PROXY protocol speaking proxy IP addresses/subnets. Only effective when "enable-proxy-protocol" is enabled, and
|
||||
# should really only be used when you are not able to use a proper firewall (usually true with shared hosting providers etc.).
|
||||
# Keeping this list empty means there is no IP address whitelist.
|
||||
# Both IP addresses and subnets are supported.
|
||||
#proxy-protocol-whitelisted-ips: [ "127.0.0.1", "172.18.0.0/16" ]
|
||||
remote:
|
||||
# The IP address of the remote (Java Edition) server
|
||||
# If it is "auto", for standalone version the remote address will be set to 127.0.0.1,
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren