Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/GeyserMC/Geyser into serv…
Browse files Browse the repository at this point in the history
…er-inventory
  • Loading branch information
Camotoy committed Feb 18, 2021
2 parents 22c39d2 + c4573bb commit 85b8fe2
Show file tree
Hide file tree
Showing 25 changed files with 509 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void onEnable() {
}
}

if (geyserConfig.getBedrock().isCloneRemotePort()){
if (geyserConfig.getBedrock().isCloneRemotePort()) {
geyserConfig.getBedrock().setPort(geyserConfig.getRemote().getPort());
}

Expand Down
57 changes: 51 additions & 6 deletions connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
</parent>
<artifactId>connector</artifactId>

<properties>
<netty.version>4.1.59.Final</netty.version>
</properties>

<dependencies>
<dependency>
<groupId>org.geysermc</groupId>
Expand All @@ -26,25 +30,30 @@
<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>
</exclusion>
</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>
Expand Down Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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;
Expand Down Expand Up @@ -196,7 +197,13 @@ private GeyserConnector(PlatformType platformType, GeyserBootstrap bootstrap) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@

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 {
Expand Down Expand Up @@ -106,6 +108,15 @@ interface IBedrockConfiguration {
String getMotd2();

String getServerName();

boolean isEnableProxyProtocol();

List<String> getProxyProtocolWhitelistedIPs();

/**
* @return Unmodifiable list of {@link CIDRMatcher}s from {@link #getProxyProtocolWhitelistedIPs()}
*/
List<CIDRMatcher> getWhitelistedIPsMatchers();
}

interface IRemoteConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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";
Expand All @@ -137,9 +143,33 @@ public static class BedrockConfiguration implements IBedrockConfiguration {

@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)
Expand Down Expand Up @@ -173,6 +203,7 @@ public static class UserAuthenticationInfo implements IUserAuthenticationInfo {
}

@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
public static class MetricsInfo implements IMetricsInfo {
private boolean enabled = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession s
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void moveRelative(GeyserSession session, double relX, double relY, double
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,21 @@
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;
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 {

Expand Down Expand Up @@ -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);
}

Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
Loading

0 comments on commit 85b8fe2

Please sign in to comment.