Skip to content

Commit

Permalink
Merge branch 'feature/plugins' into bleeding
Browse files Browse the repository at this point in the history
# Conflicts:
#	connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
  • Loading branch information
bundabrg committed Feb 24, 2021
2 parents d7cc808 + abc845b commit ff6f71b
Show file tree
Hide file tree
Showing 53 changed files with 1,071 additions and 397 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void onEnable() {
}
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition;
import lombok.Getter;
import net.minecrell.terminalconsole.TerminalConsoleAppender;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.Logger;
Expand Down Expand Up @@ -168,11 +169,6 @@ public void onEnable(boolean useGui, String configFilename) {
this.onEnable();
}

public void onEnable(boolean useGui) {
this.useGui = useGui;
this.onEnable();
}

@Override
public void onEnable() {
Logger logger = (Logger) LogManager.getRootLogger();
Expand Down Expand Up @@ -214,6 +210,9 @@ public void onEnable() {
}
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);

// Allow libraries like Protocol to have their debug information passthrough
logger.get().setLevel(geyserConfig.isDebugMode() ? Level.DEBUG : Level.INFO);

connector = GeyserConnector.start(PlatformType.STANDALONE, this);
geyserCommandManager = new GeyserCommandManager(connector);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void checkLoopback(GeyserStandaloneLogger geyserLogger) {

if (!result.contains("minecraftuwp")) {
Files.write(Paths.get(System.getenv("temp") + "/loopback_minecraft.bat"), loopbackCommand.getBytes(), new OpenOption[0]);
process = Runtime.getRuntime().exec(startScript);
Runtime.getRuntime().exec(startScript);

geyserLogger.info(ChatColor.AQUA + LanguageUtils.getLocaleStringLog("geyser.bootstrap.loopback.added"));
}
Expand Down
73 changes: 56 additions & 17 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 @@ -20,37 +24,36 @@
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.9.8</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.8</version>
<version>2.10.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.CloudburstMC.Protocol</groupId>
<artifactId>bedrock-v422</artifactId>
<version>d41b84e86c</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 @@ -153,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 All @@ -175,25 +214,25 @@
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.3.0</version>
<version>4.5.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson</artifactId>
<version>4.3.0</version>
<version>4.5.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-legacy</artifactId>
<version>4.3.0</version>
<version>4.5.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-gson-legacy-impl</artifactId>
<version>4.3.0</version>
<version>4.5.0</version>
<scope>compile</scope>
</dependency>
<dependency>
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 @@ -59,10 +60,7 @@
import org.geysermc.connector.network.translators.world.block.entity.BlockEntityTranslator;
import org.geysermc.connector.network.translators.world.block.entity.SkullBlockEntityTranslator;
import org.geysermc.connector.event.events.geyser.GeyserStopEvent;
import org.geysermc.connector.utils.DimensionUtils;
import org.geysermc.connector.utils.LanguageUtils;
import org.geysermc.connector.utils.LocaleUtils;
import org.geysermc.connector.utils.ResourcePack;
import org.geysermc.connector.utils.*;

import javax.naming.directory.Attribute;
import javax.naming.directory.InitialDirContext;
Expand All @@ -83,7 +81,8 @@ public class GeyserConnector {
.enable(JsonParser.Feature.IGNORE_UNDEFINED)
.enable(JsonParser.Feature.ALLOW_COMMENTS)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES);
.enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES)
.enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES);

public static final String NAME = "Geyser";
public static final String GIT_VERSION = "DEV"; // A fallback for running in IDEs
Expand Down Expand Up @@ -201,14 +200,21 @@ private GeyserConnector(PlatformType platformType, GeyserBootstrap bootstrap) {
remoteServer = new RemoteServer(config.getRemote().getAddress(), remotePort);
authType = AuthType.getByName(config.getRemote().getAuthType());

CooldownUtils.setShowCooldown(config.isShowCooldown());
DimensionUtils.changeBedrockNetherId(config.isAboveBedrockNetherBuilding()); // Apply End dimension ID workaround to Nether
SkullBlockEntityTranslator.ALLOW_CUSTOM_SKULLS = config.isAllowCustomSkulls();

// https://github.com/GeyserMC/Geyser/issues/957
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 @@ -52,7 +52,7 @@ public void displayMessage() {
* @return The formatted message
*/
private String createMessage() {
String message = "";
StringBuilder message = new StringBuilder();

InputStream helpStream = IGeyserMain.class.getClassLoader().getResourceAsStream("languages/run-help/" + Locale.getDefault().toString() + ".txt");

Expand All @@ -68,10 +68,10 @@ private String createMessage() {
line = line.replace("${plugin_type}", this.getPluginType());
line = line.replace("${plugin_folder}", this.getPluginFolder());

message += line + "\n";
message.append(line).append("\n");
}

return message;
return message.toString();
}

/**
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 @@ -59,6 +61,8 @@ public interface GeyserConfiguration {

int getPingPassthroughInterval();

boolean isForwardPlayerPing();

int getMaxPlayers();

boolean isDebugMode();
Expand Down Expand Up @@ -104,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 @@ -74,6 +79,9 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
@JsonProperty("ping-passthrough-interval")
private int pingPassthroughInterval = 3;

@JsonProperty("forward-player-ping")
private boolean forwardPlayerPing = false;

@JsonProperty("max-players")
private int maxPlayers = 100;

Expand Down Expand Up @@ -119,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 @@ -134,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 @@ -170,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
Loading

0 comments on commit ff6f71b

Please sign in to comment.