mirror of
https://github.com/GeyserMC/GeyserConnect.git
synced 2025-06-26 14:15:22 +02:00
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 org.geysermc.connect.utils.Server;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -72,6 +73,9 @@ public class GeyserConnectConfig {
|
||||||
|
|
||||||
@JsonProperty("debug-mode")
|
@JsonProperty("debug-mode")
|
||||||
private boolean debugMode;
|
private boolean debugMode;
|
||||||
|
|
||||||
|
@JsonProperty("saved-user-logins")
|
||||||
|
private List<String> savedUserLogins = Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|
|
@ -77,6 +77,12 @@ public class GeyserProxyBootstrap implements GeyserBootstrap {
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
|
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
|
||||||
geyserConfig = objectMapper.readValue(text, GeyserProxyConfiguration.class);
|
geyserConfig = objectMapper.readValue(text, GeyserProxyConfiguration.class);
|
||||||
|
|
||||||
|
geyserConfig.getSavedUserLogins().clear();
|
||||||
|
for (String savedUserLogin : MasterServer.getInstance().getGeyserConnectConfig().getGeyser().getSavedUserLogins()) {
|
||||||
|
geyserConfig.getSavedUserLogins().add(savedUserLogin);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
geyserLogger.severe("Failed to read proxy_config.yml! Make sure it's up to date and/or readable+writable!", ex);
|
geyserLogger.severe("Failed to read proxy_config.yml! Make sure it's up to date and/or readable+writable!", ex);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -237,6 +237,7 @@ public class Player {
|
||||||
session.sendPacket(transferPacket);
|
session.sendPacket(transferPacket);
|
||||||
} else {
|
} else {
|
||||||
GeyserProxySession geyserSession = createGeyserSession(true);
|
GeyserProxySession geyserSession = createGeyserSession(true);
|
||||||
|
GeyserImpl geyser = geyserSession.getGeyser();
|
||||||
|
|
||||||
geyserSession.setDimension(DimensionUtils.THE_END);
|
geyserSession.setDimension(DimensionUtils.THE_END);
|
||||||
|
|
||||||
|
@ -249,6 +250,13 @@ public class Player {
|
||||||
initializedPacket.setRuntimeEntityId(geyserSession.getPlayerEntity().getGeyserId());
|
initializedPacket.setRuntimeEntityId(geyserSession.getPlayerEntity().getGeyserId());
|
||||||
session.getPacketHandler().handle(initializedPacket);
|
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) {
|
if (geyserSession.getRemoteAuthType() != AuthType.ONLINE) {
|
||||||
geyserSession.authenticate(geyserSession.getAuthData().name());
|
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
|
# If debug messages should be sent through console, has to be enabled in both places to work
|
||||||
debug-mode: false
|
debug-mode: false
|
||||||
|
|
||||||
|
saved-user-logins:
|
||||||
|
- ThisExampleUsernameShouldBeLongEnoughToNeverBeAnXboxUsername
|
||||||
|
- ThisOtherExampleUsernameShouldAlsoBeLongEnough
|
||||||
|
|
||||||
# A global list of servers sent to all clients
|
# A global list of servers sent to all clients
|
||||||
servers:
|
servers:
|
||||||
- name: The Hive
|
- name: The Hive
|
||||||
|
|
|
@ -62,20 +62,9 @@ remote:
|
||||||
# You can ignore this when not using Floodgate.
|
# You can ignore this when not using Floodgate.
|
||||||
floodgate-key-file: public-key.pem
|
floodgate-key-file: public-key.pem
|
||||||
|
|
||||||
# The Xbox/Minecraft Bedrock username is the key for the Java server auth-info.
|
saved-user-logins:
|
||||||
# This allows automatic configuration/login to the remote Java server.
|
- ThisExampleUsernameShouldBeLongEnoughToNeverBeAnXboxUsername
|
||||||
# If you are brave enough to put your Mojang account info into a config file.
|
- ThisOtherExampleUsernameShouldAlsoBeLongEnough
|
||||||
# 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
|
|
||||||
|
|
||||||
# Bedrock clients can freeze when opening up the command prompt for the first time if given a lot of commands.
|
# 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.
|
# Disabling this will prevent command suggestions from being sent and solve freezing for Bedrock clients.
|
||||||
|
|
Loading…
Add table
Reference in a new issue