Fix disconnect message when forge server is offline
This commit is contained in:
parent
69ae2401af
commit
3cafdd6dfb
|
|
@ -18,6 +18,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.TranslatableComponent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.adde0109.ambassador.AmbassadorConfig;
|
import org.adde0109.ambassador.AmbassadorConfig;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
@ -114,6 +115,10 @@ public class ForgeHandshakeHandler {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onKickedFromServerEvent(KickedFromServerEvent event, Continuation continuation) {
|
public void onKickedFromServerEvent(KickedFromServerEvent event, Continuation continuation) {
|
||||||
|
if (event.getServerKickReason().isPresent()) {
|
||||||
|
Component reason = event.getServerKickReason().get();
|
||||||
|
if (reason instanceof TranslatableComponent)
|
||||||
|
if (((TranslatableComponent) reason).key().equals("multiplayer.disconnect.unexpected_query_response")) {
|
||||||
if (getForgeServerConnection(event.getServer()).isPresent() && getForgeConnection(event.getPlayer()).isEmpty()) {
|
if (getForgeServerConnection(event.getServer()).isPresent() && getForgeConnection(event.getPlayer()).isEmpty()) {
|
||||||
//Turns out the server the vanilla client is connecting to is forge. Let's handle the connection error.
|
//Turns out the server the vanilla client is connecting to is forge. Let's handle the connection error.
|
||||||
logger.info("Vanilla player {} tried to connect to forge server {}. The connection error can be ignored.",
|
logger.info("Vanilla player {} tried to connect to forge server {}. The connection error can be ignored.",
|
||||||
|
|
@ -129,6 +134,8 @@ public class ForgeHandshakeHandler {
|
||||||
event.setResult(KickedFromServerEvent.Notify.create(component));
|
event.setResult(KickedFromServerEvent.Notify.create(component));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
continuation.resume();
|
continuation.resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user