Change config and fixed some bugs
This commit is contained in:
parent
cd8df2c5a0
commit
9c5f49f6e9
|
|
@ -5,7 +5,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "org.adde0109"
|
group = "org.adde0109"
|
||||||
version = "1.4.0-beta-rc4"
|
version = "1.4.0-beta-rc7"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19;
|
||||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19_3;
|
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_19_3;
|
||||||
import static com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentIdentifier.mapSet;
|
import static com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentIdentifier.mapSet;
|
||||||
|
|
||||||
@Plugin(id = "ambassador", name = "Ambassador", version = "1.4.0-beta-rc4", authors = {"adde0109"})
|
@Plugin(id = "ambassador", name = "Ambassador", version = "1.4.0-beta-rc7", authors = {"adde0109"})
|
||||||
public class Ambassador {
|
public class Ambassador {
|
||||||
|
|
||||||
public ProxyServer server;
|
public ProxyServer server;
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,6 @@ import java.nio.file.Path;
|
||||||
|
|
||||||
public class AmbassadorConfig {
|
public class AmbassadorConfig {
|
||||||
|
|
||||||
@Expose
|
|
||||||
private int resetTimeout = 1000;
|
|
||||||
|
|
||||||
@Expose
|
@Expose
|
||||||
private String disconnectResetMessage = "Please reconnect";
|
private String disconnectResetMessage = "Please reconnect";
|
||||||
|
|
@ -26,21 +24,13 @@ public class AmbassadorConfig {
|
||||||
|
|
||||||
private net.kyori.adventure.text.@MonotonicNonNull Component messageAsAsComponent;
|
private net.kyori.adventure.text.@MonotonicNonNull Component messageAsAsComponent;
|
||||||
|
|
||||||
private AmbassadorConfig(int resetTimeout, String kickResetMessage, int serverSwitchCancellationTime, boolean silenceWarnings) {
|
private AmbassadorConfig(String kickResetMessage, int serverSwitchCancellationTime, boolean silenceWarnings) {
|
||||||
this.resetTimeout = resetTimeout;
|
|
||||||
this.disconnectResetMessage = kickResetMessage;
|
this.disconnectResetMessage = kickResetMessage;
|
||||||
this.serverSwitchCancellationTime = serverSwitchCancellationTime;
|
this.serverSwitchCancellationTime = serverSwitchCancellationTime;
|
||||||
this.silenceWarnings = silenceWarnings;
|
this.silenceWarnings = silenceWarnings;
|
||||||
};
|
};
|
||||||
|
|
||||||
public void validate() {
|
public void validate() {
|
||||||
final int connectionTimeout = Ambassador.getInstance().server.getConfiguration().getReadTimeout();
|
|
||||||
if (resetTimeout >= connectionTimeout) {
|
|
||||||
throw new InvalidValueException("'reset-timeout' can't be more than nor equal to 'read-timeout': reset-timeout=" + resetTimeout + " connection-timeout=" + connectionTimeout);
|
|
||||||
}
|
|
||||||
if (resetTimeout <= 0) {
|
|
||||||
throw new InvalidValueException("'reset-timeout' can't be less than nor equal to zero: reset-timeout=" + resetTimeout);
|
|
||||||
}
|
|
||||||
if (serverSwitchCancellationTime <= 0) {
|
if (serverSwitchCancellationTime <= 0) {
|
||||||
throw new InvalidValueException("'server-switch-cancellation-time' can't be less than nor equal to zero: server-switch-cancellation-time=" + serverSwitchCancellationTime);
|
throw new InvalidValueException("'server-switch-cancellation-time' can't be less than nor equal to zero: server-switch-cancellation-time=" + serverSwitchCancellationTime);
|
||||||
}
|
}
|
||||||
|
|
@ -70,20 +60,15 @@ public class AmbassadorConfig {
|
||||||
|
|
||||||
if (configVersion < 1.1) {
|
if (configVersion < 1.1) {
|
||||||
config.set("silence-warnings", false);
|
config.set("silence-warnings", false);
|
||||||
config.set("config-version", "1.1");
|
config.set("config-version", "1.2");
|
||||||
}
|
}
|
||||||
|
|
||||||
int resetTimeout = config.getIntOrElse("reset-timeout", 3000);
|
|
||||||
String kickResetMessage = config.getOrElse("disconnect-reset-message", "Please reconnect");
|
String kickResetMessage = config.getOrElse("disconnect-reset-message", "Please reconnect");
|
||||||
int serverSwitchCancellationTime = config.getIntOrElse("server-switch-cancellation-time", 120);
|
int serverSwitchCancellationTime = config.getIntOrElse("server-switch-cancellation-time", 120);
|
||||||
|
|
||||||
boolean silenceWarnings = config.getOrElse("silence-warnings", false);
|
boolean silenceWarnings = config.getOrElse("silence-warnings", false);
|
||||||
|
|
||||||
return new AmbassadorConfig(resetTimeout, kickResetMessage, serverSwitchCancellationTime, silenceWarnings);
|
return new AmbassadorConfig(kickResetMessage, serverSwitchCancellationTime, silenceWarnings);
|
||||||
}
|
|
||||||
|
|
||||||
public int getResetTimeout() {
|
|
||||||
return resetTimeout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public net.kyori.adventure.text.Component getDisconnectResetMessage() {
|
public net.kyori.adventure.text.Component getDisconnectResetMessage() {
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,9 @@ public enum VelocityForgeBackendConnectionPhase implements BackendConnectionPhas
|
||||||
|
|
||||||
//Reset client if not ready to receive new handshake
|
//Reset client if not ready to receive new handshake
|
||||||
VelocityForgeClientConnectionPhase clientPhase = (VelocityForgeClientConnectionPhase) player.getPhase();
|
VelocityForgeClientConnectionPhase clientPhase = (VelocityForgeClientConnectionPhase) player.getPhase();
|
||||||
clientPhase.resetConnectionPhase(player);
|
if (clientPhase != VelocityForgeClientConnectionPhase.NOT_STARTED) {
|
||||||
|
clientPhase.resetConnectionPhase(player);
|
||||||
|
}
|
||||||
message.retain();
|
message.retain();
|
||||||
player.getConnection().write(message);
|
player.getConnection().write(message);
|
||||||
//Forge server
|
//Forge server
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ public enum VelocityForgeClientConnectionPhase implements ClientConnectionPhase
|
||||||
|
|
||||||
if (connection.getState() == StateRegistry.PLAY) {
|
if (connection.getState() == StateRegistry.PLAY) {
|
||||||
connection.write(new PluginMessage("fml:handshake", Unpooled.wrappedBuffer(ForgeHandshakeUtils.generatePluginResetPacket())));
|
connection.write(new PluginMessage("fml:handshake", Unpooled.wrappedBuffer(ForgeHandshakeUtils.generatePluginResetPacket())));
|
||||||
|
connection.setState(StateRegistry.LOGIN);
|
||||||
} else {
|
} else {
|
||||||
connection.write(new LoginPluginMessage(98,"fml:loginwrapper", Unpooled.wrappedBuffer(ForgeHandshakeUtils.generateResetPacket())));
|
connection.write(new LoginPluginMessage(98,"fml:loginwrapper", Unpooled.wrappedBuffer(ForgeHandshakeUtils.generateResetPacket())));
|
||||||
}
|
}
|
||||||
|
|
@ -98,7 +99,6 @@ public enum VelocityForgeClientConnectionPhase implements ClientConnectionPhase
|
||||||
if (msg.getId() == 98) {
|
if (msg.getId() == 98) {
|
||||||
player.getConnection().getChannel().pipeline().remove(ForgeConstants.RESET_LISTENER);
|
player.getConnection().getChannel().pipeline().remove(ForgeConstants.RESET_LISTENER);
|
||||||
player.setPhase(NOT_STARTED);
|
player.setPhase(NOT_STARTED);
|
||||||
player.getConnection().setState(StateRegistry.LOGIN);
|
|
||||||
|
|
||||||
player.getConnection().getChannel().pipeline().remove(ForgeConstants.LOGIN_PACKET_QUEUE);
|
player.getConnection().getChannel().pipeline().remove(ForgeConstants.LOGIN_PACKET_QUEUE);
|
||||||
|
|
||||||
|
|
@ -133,7 +133,6 @@ public enum VelocityForgeClientConnectionPhase implements ClientConnectionPhase
|
||||||
buf.writeBytes((player.getVirtualHost().get().getHostName() + ":"
|
buf.writeBytes((player.getVirtualHost().get().getHostName() + ":"
|
||||||
+ player.getVirtualHost().get().getPort()).getBytes(StandardCharsets.UTF_8));
|
+ player.getVirtualHost().get().getPort()).getBytes(StandardCharsets.UTF_8));
|
||||||
player.getConnection().write(new PluginMessage("srvredirect:red", buf));
|
player.getConnection().write(new PluginMessage("srvredirect:red", buf));
|
||||||
player.getConnection().close();
|
|
||||||
} else {
|
} else {
|
||||||
player.disconnect(Ambassador.getInstance().config.getDisconnectResetMessage());
|
player.disconnect(Ambassador.getInstance().config.getDisconnectResetMessage());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,10 +49,12 @@ public class ForgeLoginSessionHandler implements MinecraftSessionHandler {
|
||||||
}
|
}
|
||||||
ConnectedPlayer player = serverConnection.getPlayer();
|
ConnectedPlayer player = serverConnection.getPlayer();
|
||||||
if (!(serverConnection.getConnection().getType() instanceof ForgeFMLConnectionType)) {
|
if (!(serverConnection.getConnection().getType() instanceof ForgeFMLConnectionType)) {
|
||||||
|
if (player.getConnection() == null || player.getConnection().getType() instanceof ForgeFMLConnectionType) {
|
||||||
//Initial Vanilla
|
//Initial Vanilla
|
||||||
//Forge -> vanilla
|
//Forge -> vanilla
|
||||||
player.getPhase().resetConnectionPhase(player);
|
player.getPhase().resetConnectionPhase(player);
|
||||||
player.getConnectionInFlight().getConnection().getChannel().config().setAutoRead(false);
|
player.getConnectionInFlight().getConnection().getChannel().config().setAutoRead(false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
((VelocityForgeClientConnectionPhase) player.getPhase()).complete(player);
|
((VelocityForgeClientConnectionPhase) player.getPhase()).complete(player);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
# Do not change this
|
# Do not change this
|
||||||
config-version = "1.1"
|
config-version = "1.1"
|
||||||
|
|
||||||
# How long to wait for the client to reset before disconnecting (In milliseconds)
|
|
||||||
reset-timeout = 3000
|
|
||||||
# Message displayed to the player when disconnected from proxy during server switch.
|
# Message displayed to the player when disconnected from proxy during server switch.
|
||||||
# Legacy color codes and JSON are accepted.
|
# Legacy color codes and JSON are accepted.
|
||||||
disconnect-reset-message = "&6Please reconnect"
|
disconnect-reset-message = "&6Please reconnect"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user