13
0
geforkt von Mirrors/Velocity

Merge pull request #79 from Leymooo/force-offline

expand PreLoginComponentResult with force offline mode
Dieser Commit ist enthalten in:
Andrew Steinborn 2018-09-12 20:22:26 -04:00 committet von GitHub
Commit b24418bfee
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 24 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -52,35 +52,42 @@ public class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLoginCompon
}
/**
* Represents an "allowed/allowed with online mode/denied" result with a reason allowed for denial.
* Represents an "allowed/allowed with forced online\offline mode/denied" result with a reason allowed for denial.
*/
public static class PreLoginComponentResult extends ResultedEvent.ComponentResult {
private static final PreLoginComponentResult ALLOWED = new PreLoginComponentResult((Component) null);
private static final PreLoginComponentResult FORCE_ONLINEMODE = new PreLoginComponentResult(true);
private static final PreLoginComponentResult FORCE_ONLINEMODE = new PreLoginComponentResult(true, false);
private static final PreLoginComponentResult FORCE_OFFLINEMODE = new PreLoginComponentResult(false, true);
private final boolean onlineMode;
private final boolean forceOfflineMode;
/**
* Allows online mode to be enabled for the player connection, if Velocity is running in offline mode.
* @param allowedOnlineMode if true, online mode will be used for the connection
*/
private PreLoginComponentResult(boolean allowedOnlineMode) {
private PreLoginComponentResult(boolean allowedOnlineMode, boolean forceOfflineMode) {
super(true, null);
this.onlineMode = allowedOnlineMode;
this.forceOfflineMode = forceOfflineMode;
}
private PreLoginComponentResult(@Nullable Component reason) {
super(reason == null, reason);
// Don't care about this
this.onlineMode = false;
this.forceOfflineMode = false;
}
public boolean isOnlineModeAllowed() {
return this.onlineMode;
}
public boolean isForceOfflineMode() {
return forceOfflineMode;
}
@Override
public String toString() {
if (isForceOfflineMode()) {
return "allowed with force offline mode";
}
if (isOnlineModeAllowed()) {
return "allowed with online mode";
}
@ -106,6 +113,15 @@ public class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLoginCompon
return FORCE_ONLINEMODE;
}
/**
* Returns a result indicating the connection will be allowed through the proxy, but the connection will be
* forced to use offline mode even when proxy running in online mode
* @return the result
*/
public static PreLoginComponentResult forceOfflineMode() {
return FORCE_OFFLINEMODE;
}
/**
* Denies the login with the specified reason.
* @param reason the reason for disallowing the connection

Datei anzeigen

@ -159,7 +159,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
return;
}
if (server.getConfiguration().isOnlineMode() || result.isOnlineModeAllowed()) {
if (!result.isForceOfflineMode() && (server.getConfiguration().isOnlineMode() || result.isOnlineModeAllowed())) {
// Request encryption.
EncryptionRequest request = generateRequest();
this.verify = Arrays.copyOf(request.getVerifyToken(), 4);