Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
expand PreLoginComponentResult with force offline mode
Dieser Commit ist enthalten in:
Ursprung
ab2c887e2c
Commit
bc86a12c57
@ -56,31 +56,41 @@ public class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLoginCompon
|
|||||||
*/
|
*/
|
||||||
public static class PreLoginComponentResult extends ResultedEvent.ComponentResult {
|
public static class PreLoginComponentResult extends ResultedEvent.ComponentResult {
|
||||||
private static final PreLoginComponentResult ALLOWED = new PreLoginComponentResult((Component) null);
|
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 onlineMode;
|
||||||
|
private final boolean forceOfflineMode;
|
||||||
/**
|
/**
|
||||||
* Allows online mode to be enabled for the player connection, if Velocity is running in offline mode.
|
* 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
|
* @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);
|
super(true, null);
|
||||||
this.onlineMode = allowedOnlineMode;
|
this.onlineMode = allowedOnlineMode;
|
||||||
|
this.forceOfflineMode = forceOfflineMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PreLoginComponentResult(@Nullable Component reason) {
|
private PreLoginComponentResult(@Nullable Component reason) {
|
||||||
super(reason == null, reason);
|
super(reason == null, reason);
|
||||||
// Don't care about this
|
// Don't care about this
|
||||||
this.onlineMode = false;
|
this.onlineMode = false;
|
||||||
|
this.forceOfflineMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOnlineModeAllowed() {
|
public boolean isOnlineModeAllowed() {
|
||||||
return this.onlineMode;
|
return this.onlineMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isForceOfflineMode() {
|
||||||
|
return forceOfflineMode;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
if (isForceOfflineMode()) {
|
||||||
|
return "allowed with force offline mode";
|
||||||
|
}
|
||||||
if (isOnlineModeAllowed()) {
|
if (isOnlineModeAllowed()) {
|
||||||
return "allowed with online mode";
|
return "allowed with online mode";
|
||||||
}
|
}
|
||||||
@ -106,6 +116,15 @@ public class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLoginCompon
|
|||||||
return FORCE_ONLINEMODE;
|
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.
|
* Denies the login with the specified reason.
|
||||||
* @param reason the reason for disallowing the connection
|
* @param reason the reason for disallowing the connection
|
||||||
|
@ -159,7 +159,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server.getConfiguration().isOnlineMode() || result.isOnlineModeAllowed()) {
|
if (!result.isForceOfflineMode() && (server.getConfiguration().isOnlineMode() || result.isOnlineModeAllowed())) {
|
||||||
// Request encryption.
|
// Request encryption.
|
||||||
EncryptionRequest request = generateRequest();
|
EncryptionRequest request = generateRequest();
|
||||||
this.verify = Arrays.copyOf(request.getVerifyToken(), 4);
|
this.verify = Arrays.copyOf(request.getVerifyToken(), 4);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren