forked from GeyserMC/Geyser
Add config file and reader
- Added Jackson as a dependency to load/parse YML - Added a default config.yml - Added lombok as a dependency - Removed SnakeYAML
This commit is contained in:
parent
9402e2a445
commit
7afae0ae02
7 changed files with 217 additions and 3 deletions
|
@ -19,9 +19,14 @@
|
|||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>1.19</version>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||
<version>2.9.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>2.9.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.sentry</groupId>
|
||||
|
@ -34,6 +39,45 @@
|
|||
<version>1.0.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.6.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>27.0.1-jre</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nukkitx.protocol</groupId>
|
||||
<artifactId>bedrock-v354</artifactId>
|
||||
<version>2.0.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nukkitx.protocol</groupId>
|
||||
<artifactId>bedrock-v340</artifactId>
|
||||
<version>2.0.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nukkitx.protocol</groupId>
|
||||
<artifactId>bedrock-v332</artifactId>
|
||||
<version>2.0.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>${outputName}-noshade</finalName>
|
||||
|
|
|
@ -14,24 +14,38 @@
|
|||
|
||||
package org.geysermc.connector;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
||||
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
|
||||
import com.nukkitx.protocol.bedrock.v354.Bedrock_v354;
|
||||
import org.geysermc.api.ChatColor;
|
||||
import org.geysermc.connector.command.GeyserCommandMap;
|
||||
import org.geysermc.connector.configuration.GeyserConfiguration;
|
||||
import org.geysermc.connector.console.ConsoleCommandReader;
|
||||
import org.geysermc.connector.console.GeyserLogger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
public class GeyserConnector {
|
||||
|
||||
public static final BedrockPacketCodec BEDROCK_PACKET_CODEC = Bedrock_v354.V354_CODEC;
|
||||
|
||||
private static final String NAME = "Geyser";
|
||||
private static final String VERSION = "1.0-SNAPSHOT";
|
||||
|
||||
private static GeyserConnector instance;
|
||||
|
||||
private boolean shuttingDown = false;
|
||||
|
||||
private GeyserLogger logger;
|
||||
private GeyserCommandMap commandMap;
|
||||
private GeyserConfiguration config;
|
||||
|
||||
private final ScheduledExecutorService generalThreadPool;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -53,6 +67,24 @@ public class GeyserConnector {
|
|||
logger.info("");
|
||||
logger.info("******************************************");
|
||||
|
||||
try {
|
||||
File configFile = new File("config.yml");
|
||||
if (!configFile.exists()) {
|
||||
FileOutputStream fos = new FileOutputStream(configFile);
|
||||
InputStream is = GeyserConnector.class.getResourceAsStream("/config.yml");
|
||||
int data;
|
||||
while ((data = is.read()) != -1)
|
||||
fos.write(data);
|
||||
is.close();
|
||||
fos.close();
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
|
||||
config = objectMapper.readValue(configFile, GeyserConfiguration.class);
|
||||
} catch (IOException ex) {
|
||||
logger.severe("Failed to create config.yml! Make sure it's up to date and writable!");
|
||||
shutdown();
|
||||
}
|
||||
commandMap = new GeyserCommandMap(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* Version 3, 29 June 2007
|
||||
*
|
||||
* Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
* Everyone is permitted to copy and distribute verbatim copies
|
||||
* of this license document, but changing it is not allowed.
|
||||
*
|
||||
* You can view the LICENCE file for details.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.connector.configuration;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class BedrockConfiguration {
|
||||
|
||||
private String address;
|
||||
private int port;
|
||||
|
||||
private String motd1;
|
||||
private String motd2;
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public String getMotd1() {
|
||||
return motd1;
|
||||
}
|
||||
|
||||
public String getMotd2() {
|
||||
return motd2;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* Version 3, 29 June 2007
|
||||
*
|
||||
* Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
* Everyone is permitted to copy and distribute verbatim copies
|
||||
* of this license document, but changing it is not allowed.
|
||||
*
|
||||
* You can view the LICENCE file for details.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.connector.configuration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class GeyserConfiguration {
|
||||
|
||||
private BedrockConfiguration bedrock;
|
||||
private RemoteConfiguration remote;
|
||||
|
||||
@JsonProperty("ping-passthrough")
|
||||
private boolean pingPassthrough;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* Version 3, 29 June 2007
|
||||
*
|
||||
* Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
* Everyone is permitted to copy and distribute verbatim copies
|
||||
* of this license document, but changing it is not allowed.
|
||||
*
|
||||
* You can view the LICENCE file for details.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.connector.configuration;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class RemoteConfiguration {
|
||||
|
||||
private String address;
|
||||
private int port;
|
||||
|
||||
private String motd1;
|
||||
private String motd2;
|
||||
|
||||
@JsonProperty("online-mode")
|
||||
private boolean onlineMode;
|
||||
}
|
30
connector/src/main/resources/config.yml
Normal file
30
connector/src/main/resources/config.yml
Normal file
|
@ -0,0 +1,30 @@
|
|||
# --------------------------------
|
||||
# Geyser Configuration File
|
||||
#
|
||||
# A bridge between Minecraft: Bedrock Edition and Minecraft: Java Edition.
|
||||
#
|
||||
# https://github.com/GeyserMC/Geyser
|
||||
# --------------------------------
|
||||
|
||||
bedrock:
|
||||
# The IP address that will listen for connections
|
||||
address: 0.0.0.0
|
||||
# The port that will listen for connections
|
||||
port: 19132
|
||||
# The MOTD that will be broadcasted to Minecraft: Bedrock Edition clients
|
||||
motd1: "GeyserMC"
|
||||
motd2: "Another GeyserMC forced host."
|
||||
remote:
|
||||
# The IP address of the remote (Java Edition) server
|
||||
address: 127.0.0.1
|
||||
# The port of the remote (Java Edition) server
|
||||
port: 25565
|
||||
online-mode: true
|
||||
|
||||
# Relay the MOTD, player count and max players from the remote server
|
||||
ping-passthrough: false
|
||||
|
||||
|
||||
|
||||
|
||||
|
4
pom.xml
4
pom.xml
|
@ -43,6 +43,10 @@
|
|||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>nukkitx-repo</id>
|
||||
<url>https://repo.nukkitx.com/maven-releases/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
|
|
Loading…
Reference in a new issue