forked from GeyserMC/Geyser
Automatic ip & port for plugins (#438)
* Automatically set Bukkit ip and port * Automatically set Velocity ip and port * Automatically set BungeeCord ip and port * Moved the config init line to prevent config issues * Automatically set Sponge ip and port
This commit is contained in:
parent
fc17b7cc7a
commit
7f29710006
5 changed files with 76 additions and 10 deletions
|
@ -27,9 +27,8 @@ package org.geysermc.platform.velocity;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import lombok.Setter;
|
||||
import org.geysermc.common.IGeyserConfiguration;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
@ -86,7 +85,10 @@ public class GeyserVelocityConfiguration implements IGeyserConfiguration {
|
|||
@Getter
|
||||
public static class RemoteConfiguration implements IRemoteConfiguration {
|
||||
|
||||
@Setter
|
||||
private String address;
|
||||
|
||||
@Setter
|
||||
private int port;
|
||||
|
||||
private String motd1;
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
|||
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.common.bootstrap.IGeyserBootstrap;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
|
@ -43,6 +44,7 @@ import org.slf4j.Logger;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.UUID;
|
||||
|
||||
@Plugin(id = "geyser", name = GeyserConnector.NAME + "-Velocity", version = GeyserConnector.VERSION, url = "https://geysermc.org", authors = "GeyserMC")
|
||||
|
@ -51,6 +53,9 @@ public class GeyserVelocityPlugin implements IGeyserBootstrap {
|
|||
@Inject
|
||||
private Logger logger;
|
||||
|
||||
@Inject
|
||||
private ProxyServer server;
|
||||
|
||||
@Inject
|
||||
private CommandManager commandManager;
|
||||
|
||||
|
@ -73,6 +78,16 @@ public class GeyserVelocityPlugin implements IGeyserBootstrap {
|
|||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
InetSocketAddress javaAddr = server.getBoundAddress();
|
||||
|
||||
// Don't change the ip if its listening on all interfaces
|
||||
// By default this should be 127.0.0.1 but may need to be changed in some circumstances
|
||||
if (!javaAddr.getHostString().equals("0.0.0.0")) {
|
||||
geyserConfig.getRemote().setAddress(javaAddr.getHostString());
|
||||
}
|
||||
|
||||
geyserConfig.getRemote().setPort(javaAddr.getPort());
|
||||
|
||||
this.geyserLogger = new GeyserVelocityLogger(logger, geyserConfig.isDebugMode());
|
||||
this.connector = GeyserConnector.start(PlatformType.VELOCITY, this);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue