forked from git-mirrors/GeyserConnect
Support saved token system (#62)
This commit is contained in:
parent
24437d3ae8
commit
7493206025
5 changed files with 25 additions and 14 deletions
|
@ -32,6 +32,7 @@ import org.geysermc.connect.storage.AbstractStorageManager;
|
|||
import org.geysermc.connect.utils.Server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
|
@ -72,6 +73,9 @@ public class GeyserConnectConfig {
|
|||
|
||||
@JsonProperty("debug-mode")
|
||||
private boolean debugMode;
|
||||
|
||||
@JsonProperty("saved-user-logins")
|
||||
private List<String> savedUserLogins = Collections.emptyList();
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
|
|
@ -77,6 +77,12 @@ public class GeyserProxyBootstrap implements GeyserBootstrap {
|
|||
|
||||
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
|
||||
geyserConfig = objectMapper.readValue(text, GeyserProxyConfiguration.class);
|
||||
|
||||
geyserConfig.getSavedUserLogins().clear();
|
||||
for (String savedUserLogin : MasterServer.getInstance().getGeyserConnectConfig().getGeyser().getSavedUserLogins()) {
|
||||
geyserConfig.getSavedUserLogins().add(savedUserLogin);
|
||||
}
|
||||
|
||||
} catch (IOException ex) {
|
||||
geyserLogger.severe("Failed to read proxy_config.yml! Make sure it's up to date and/or readable+writable!", ex);
|
||||
return;
|
||||
|
|
|
@ -237,6 +237,7 @@ public class Player {
|
|||
session.sendPacket(transferPacket);
|
||||
} else {
|
||||
GeyserProxySession geyserSession = createGeyserSession(true);
|
||||
GeyserImpl geyser = geyserSession.getGeyser();
|
||||
|
||||
geyserSession.setDimension(DimensionUtils.THE_END);
|
||||
|
||||
|
@ -249,6 +250,13 @@ public class Player {
|
|||
initializedPacket.setRuntimeEntityId(geyserSession.getPlayerEntity().getGeyserId());
|
||||
session.getPacketHandler().handle(initializedPacket);
|
||||
|
||||
if (geyser.getConfig().getSavedUserLogins().contains(authData.name())) {
|
||||
String refreshToken = geyser.refreshTokenFor(authData.name());
|
||||
if (refreshToken != null) {
|
||||
geyserSession.authenticateWithRefreshToken(refreshToken);
|
||||
}
|
||||
}
|
||||
|
||||
if (geyserSession.getRemoteAuthType() != AuthType.ONLINE) {
|
||||
geyserSession.authenticate(geyserSession.getAuthData().name());
|
||||
}
|
||||
|
|
|
@ -31,6 +31,10 @@ geyser:
|
|||
# If debug messages should be sent through console, has to be enabled in both places to work
|
||||
debug-mode: false
|
||||
|
||||
saved-user-logins:
|
||||
- ThisExampleUsernameShouldBeLongEnoughToNeverBeAnXboxUsername
|
||||
- ThisOtherExampleUsernameShouldAlsoBeLongEnough
|
||||
|
||||
# A global list of servers sent to all clients
|
||||
servers:
|
||||
- name: The Hive
|
||||
|
|
|
@ -62,20 +62,9 @@ remote:
|
|||
# You can ignore this when not using Floodgate.
|
||||
floodgate-key-file: public-key.pem
|
||||
|
||||
# The Xbox/Minecraft Bedrock username is the key for the Java server auth-info.
|
||||
# This allows automatic configuration/login to the remote Java server.
|
||||
# If you are brave enough to put your Mojang account info into a config file.
|
||||
# Uncomment the lines below to enable this feature.
|
||||
#userAuths:
|
||||
# BedrockAccountUsername: # Your Minecraft: Bedrock Edition username
|
||||
# email: javaccountemail@example.com # Your Minecraft: Java Edition email
|
||||
# password: javaccountpassword123 # Your Minecraft: Java Edition password
|
||||
# microsoft-account: true # Whether the account is a Mojang or Microsoft account.
|
||||
#
|
||||
# bluerkelp2:
|
||||
# email: not_really_my_email_address_mr_minecrafter53267@gmail.com
|
||||
# password: "this isn't really my password"
|
||||
# microsoft-account: false
|
||||
saved-user-logins:
|
||||
- ThisExampleUsernameShouldBeLongEnoughToNeverBeAnXboxUsername
|
||||
- ThisOtherExampleUsernameShouldAlsoBeLongEnough
|
||||
|
||||
# Bedrock clients can freeze when opening up the command prompt for the first time if given a lot of commands.
|
||||
# Disabling this will prevent command suggestions from being sent and solve freezing for Bedrock clients.
|
||||
|
|
Loading…
Add table
Reference in a new issue