Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 14:30:17 +01:00
Get server to show up in server list
Dieser Commit ist enthalten in:
Ursprung
187d2dbe32
Commit
1ddef77ecc
@ -17,6 +17,7 @@ package org.geysermc.connector;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
||||||
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
|
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
|
||||||
|
import com.nukkitx.protocol.bedrock.BedrockServer;
|
||||||
import com.nukkitx.protocol.bedrock.v354.Bedrock_v354;
|
import com.nukkitx.protocol.bedrock.v354.Bedrock_v354;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.api.ChatColor;
|
import org.geysermc.api.ChatColor;
|
||||||
@ -29,6 +30,7 @@ import org.geysermc.connector.command.GeyserCommandMap;
|
|||||||
import org.geysermc.connector.configuration.GeyserConfiguration;
|
import org.geysermc.connector.configuration.GeyserConfiguration;
|
||||||
import org.geysermc.connector.console.ConsoleCommandReader;
|
import org.geysermc.connector.console.ConsoleCommandReader;
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
import org.geysermc.connector.console.GeyserLogger;
|
||||||
|
import org.geysermc.connector.network.listener.ConnectorServerEventListener;
|
||||||
import org.geysermc.connector.plugin.GeyserPluginLoader;
|
import org.geysermc.connector.plugin.GeyserPluginLoader;
|
||||||
import org.geysermc.connector.plugin.GeyserPluginManager;
|
import org.geysermc.connector.plugin.GeyserPluginManager;
|
||||||
|
|
||||||
@ -36,6 +38,7 @@ import java.io.File;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
@ -110,6 +113,17 @@ public class GeyserConnector implements Connector {
|
|||||||
|
|
||||||
pluginManager = new GeyserPluginManager(new GeyserPluginLoader(this));
|
pluginManager = new GeyserPluginManager(new GeyserPluginLoader(this));
|
||||||
pluginManager.getLoader().loadPlugins();
|
pluginManager.getLoader().loadPlugins();
|
||||||
|
|
||||||
|
BedrockServer bedrockServer = new BedrockServer(new InetSocketAddress(config.getBedrock().getAddress(), config.getBedrock().getPort()));
|
||||||
|
bedrockServer.setHandler(new ConnectorServerEventListener(this));
|
||||||
|
bedrockServer.bind().whenComplete((avoid, throwable) -> {
|
||||||
|
if (throwable == null) {
|
||||||
|
logger.info("Started RakNet on " + config.getBedrock().getAddress() + ":" + config.getBedrock().getPort());
|
||||||
|
} else {
|
||||||
|
logger.severe("Failed to start RakNet on " + config.getBedrock().getAddress() + ":" + config.getBedrock().getPort());
|
||||||
|
throwable.printStackTrace();
|
||||||
|
}
|
||||||
|
}).join();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
@ -26,5 +26,6 @@ public class GeyserConfiguration {
|
|||||||
@JsonProperty("ping-passthrough")
|
@JsonProperty("ping-passthrough")
|
||||||
private boolean pingPassthrough;
|
private boolean pingPassthrough;
|
||||||
|
|
||||||
|
@JsonProperty("max-players")
|
||||||
|
private int maxPlayers;
|
||||||
}
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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.network.listener;
|
||||||
|
|
||||||
|
import com.nukkitx.protocol.bedrock.BedrockPong;
|
||||||
|
import com.nukkitx.protocol.bedrock.BedrockServerEventHandler;
|
||||||
|
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
||||||
|
import org.geysermc.connector.GeyserConnector;
|
||||||
|
import org.geysermc.connector.configuration.GeyserConfiguration;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
|
||||||
|
public class ConnectorServerEventListener implements BedrockServerEventHandler {
|
||||||
|
|
||||||
|
private GeyserConnector connector;
|
||||||
|
|
||||||
|
public ConnectorServerEventListener(GeyserConnector connector) {
|
||||||
|
this.connector = connector;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onConnectionRequest(InetSocketAddress inetSocketAddress) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
|
||||||
|
GeyserConfiguration config = connector.getConfig();
|
||||||
|
BedrockPong pong = new BedrockPong();
|
||||||
|
pong.setEdition("MCPE");
|
||||||
|
pong.setMotd(config.getBedrock().getMotd1());
|
||||||
|
pong.setSubMotd(config.getBedrock().getMotd2());
|
||||||
|
pong.setPlayerCount(0);
|
||||||
|
pong.setMaximumPlayerCount(config.getMaxPlayers());
|
||||||
|
pong.setGameType("Default");
|
||||||
|
pong.setNintendoLimited(false);
|
||||||
|
pong.setProtocolVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getProtocolVersion());
|
||||||
|
|
||||||
|
return pong;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSessionCreation(BedrockServerSession bedrockServerSession) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,8 @@ remote:
|
|||||||
# Relay the MOTD, player count and max players from the remote server
|
# Relay the MOTD, player count and max players from the remote server
|
||||||
ping-passthrough: false
|
ping-passthrough: false
|
||||||
|
|
||||||
|
# Maximum amount of players that can connect
|
||||||
|
max-players: 100
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren