mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Add BedrockListener API and fix other stuffs
This commit is contained in:
parent
f78ba8fb4c
commit
f8e9662665
4 changed files with 133 additions and 3 deletions
|
@ -33,6 +33,7 @@ import org.geysermc.geyser.api.command.CommandManager;
|
|||
import org.geysermc.geyser.api.connection.GeyserConnection;
|
||||
import org.geysermc.geyser.api.event.EventBus;
|
||||
import org.geysermc.geyser.api.extension.ExtensionManager;
|
||||
import org.geysermc.geyser.api.network.BedrockListener;
|
||||
import org.geysermc.geyser.api.network.RemoteServer;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -112,7 +113,15 @@ public interface GeyserApi extends GeyserApiBase {
|
|||
*
|
||||
* @return the default remote server used within Geyser
|
||||
*/
|
||||
RemoteServer getDefaultRemoteServer();
|
||||
RemoteServer defaultRemoteServer();
|
||||
|
||||
/**
|
||||
* Gets the {@link BedrockListener} used for listening
|
||||
* for Minecraft: Bedrock Edition client connections.
|
||||
*
|
||||
* @return the listener used for Bedrock client connectins
|
||||
*/
|
||||
BedrockListener bedrockListener();
|
||||
|
||||
/**
|
||||
* Gets the current {@link GeyserApiBase} instance.
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2022 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.geyser.api.network;
|
||||
|
||||
/**
|
||||
* The listener that handles connections from Minecraft:
|
||||
* Bedrock Edition.
|
||||
*/
|
||||
public interface BedrockListener {
|
||||
|
||||
/**
|
||||
* Gets the address used for listening for Bedrock
|
||||
* connections from.
|
||||
*
|
||||
* @return the listening address
|
||||
*/
|
||||
String address();
|
||||
|
||||
/**
|
||||
* Gets the port used for listening for Bedrock
|
||||
* connections from.
|
||||
*
|
||||
* @return the listening port
|
||||
*/
|
||||
int port();
|
||||
|
||||
/**
|
||||
* Gets the primary MOTD shown to Bedrock players.
|
||||
* <p>
|
||||
* This is the first line that will be displayed.
|
||||
*
|
||||
* @return the primary MOTD shown to Bedrock players.
|
||||
*/
|
||||
String primaryMotd();
|
||||
|
||||
/**
|
||||
* Gets the secondary MOTD shown to Bedrock players.
|
||||
* <p>
|
||||
* This is the second line that will be displayed.
|
||||
*
|
||||
* @return the secondary MOTD shown to Bedrock players.
|
||||
*/
|
||||
String secondaryMotd();
|
||||
|
||||
/**
|
||||
* Gets the server name that is sent to Bedrock clients.
|
||||
*
|
||||
* @return the server sent to Bedrock clients
|
||||
*/
|
||||
String serverName();
|
||||
}
|
|
@ -55,6 +55,7 @@ import org.geysermc.geyser.api.event.EventBus;
|
|||
import org.geysermc.geyser.api.event.lifecycle.GeyserPostInitializeEvent;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserPreInitializeEvent;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserShutdownEvent;
|
||||
import org.geysermc.geyser.api.network.BedrockListener;
|
||||
import org.geysermc.geyser.api.network.RemoteServer;
|
||||
import org.geysermc.geyser.command.GeyserCommandManager;
|
||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||
|
@ -62,6 +63,7 @@ import org.geysermc.geyser.entity.EntityDefinitions;
|
|||
import org.geysermc.geyser.event.GeyserEventBus;
|
||||
import org.geysermc.geyser.extension.GeyserExtensionManager;
|
||||
import org.geysermc.geyser.level.WorldManager;
|
||||
import org.geysermc.geyser.network.BedrockListenerImpl;
|
||||
import org.geysermc.geyser.network.ConnectorServerEventHandler;
|
||||
import org.geysermc.geyser.network.GameProtocol;
|
||||
import org.geysermc.geyser.network.RemoteServerImpl;
|
||||
|
@ -145,6 +147,7 @@ public class GeyserImpl implements GeyserApi {
|
|||
private final GeyserExtensionManager extensionManager;
|
||||
|
||||
private final RemoteServer remoteServer;
|
||||
private final BedrockListener bedrockListener;
|
||||
|
||||
private Metrics metrics;
|
||||
|
||||
|
@ -212,6 +215,14 @@ public class GeyserImpl implements GeyserApi {
|
|||
config.getRemote().getAuthType()
|
||||
);
|
||||
|
||||
this.bedrockListener = new BedrockListenerImpl(
|
||||
config.getBedrock().getAddress(),
|
||||
config.getBedrock().getPort(),
|
||||
config.getBedrock().getMotd1(),
|
||||
config.getBedrock().getMotd2(),
|
||||
config.getBedrock().getServerName()
|
||||
);
|
||||
|
||||
double completeTime = (System.currentTimeMillis() - startupTime) / 1000D;
|
||||
String message = GeyserLocale.getLocaleStringLog("geyser.core.finish.done", new DecimalFormat("#.###").format(completeTime)) + " ";
|
||||
if (isGui) {
|
||||
|
@ -571,8 +582,13 @@ public class GeyserImpl implements GeyserApi {
|
|||
}
|
||||
|
||||
@Override
|
||||
public RemoteServer getDefaultRemoteServer() {
|
||||
return null;
|
||||
public RemoteServer defaultRemoteServer() {
|
||||
return this.remoteServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BedrockListener bedrockListener() {
|
||||
return this.bedrockListener;
|
||||
}
|
||||
|
||||
public static GeyserImpl start(PlatformType platformType, GeyserBootstrap bootstrap) {
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2022 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.geyser.network;
|
||||
|
||||
import org.geysermc.geyser.api.network.BedrockListener;
|
||||
|
||||
public record BedrockListenerImpl(String address, int port, String primaryMotd, String secondaryMotd, String serverName) implements BedrockListener {
|
||||
}
|
Loading…
Reference in a new issue