Skip to content

Commit 836dbfd

Browse files
authored
Merge pull request #321 from LossyDragon/1-6-1-patches
Post 1.6.0 updates
2 parents 17c5ad7 + 88c7439 commit 836dbfd

16 files changed

Lines changed: 583 additions & 57 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ plugins {
1818

1919
allprojects {
2020
group = "in.dragonbra"
21-
version = "1.6.0"
21+
version = "1.6.1-SNAPSHOT"
2222
}
2323

2424
repositories {

gradle/libs.versions.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@
66
[versions]
77
# Java / Kotlin versions
88
java = "11"
9-
kotlin = "2.1.0" # https://kotlinlang.org/docs/releases.html#release-details
9+
kotlin = "2.1.10" # https://kotlinlang.org/docs/releases.html#release-details
1010
dokka = "2.0.0" # https://mvnrepository.com/artifact/org.jetbrains.dokka/dokka-gradle-plugin
1111
kotlinter = "5.0.1" # https://plugins.gradle.org/plugin/org.jmailen.kotlinter
1212

1313
# Standard Library versions
14-
bouncyCastle = "1.79" # https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk18on
14+
bouncyCastle = "1.80" # https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk18on
1515
commons-io = "2.18.0" # https://mvnrepository.com/artifact/commons-io/commons-io
1616
commons-lang3 = "3.17.0" # https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
1717
commons-validator = "1.9.0" # https://mvnrepository.com/artifact/commons-validator/commons-validator
18-
gson = "2.11.0" # https://mvnrepository.com/artifact/com.google.code.gson/gson
18+
gson = "2.12.1" # https://mvnrepository.com/artifact/com.google.code.gson/gson
1919
jacoco = "0.8.12" # https://www.eclemma.org/jacoco
2020
kotlin-coroutines = "1.10.1" # https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core
2121
okHttp = "5.0.0-alpha.14" # https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
22-
protobuf = "4.29.2" # https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java
22+
protobuf = "4.29.3" # https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java
2323
protobuf-gradle = "0.9.4" # https://mvnrepository.com/artifact/com.google.protobuf/protobuf-gradle-plugin
2424
publishPlugin = "1.3.0" # https://mvnrepository.com/artifact/io.github.gradle-nexus/publish-plugin
2525
qrCode = "1.0.1" # https://mvnrepository.com/artifact/pro.leaco.qrcode/console-qrcode
2626
xz = "1.10" # https://mvnrepository.com/artifact/org.tukaani/xz
2727

2828
# Testing Lib versions
29-
commonsCodec = "1.17.1" # https://mvnrepository.com/artifact/commons-codec/commons-codec
29+
commonsCodec = "1.18.0" # https://mvnrepository.com/artifact/commons-codec/commons-codec
3030
junit5 = "5.11.4" # https://mvnrepository.com/artifact/org.junit/junit-bom
3131
mockWebServer = "5.0.0-alpha.14" # https://mvnrepository.com/artifact/com.squareup.okhttp3/mockwebserver3-junit5
32-
mockitoVersion = "5.14.2" # https://mvnrepository.com/artifact/org.mockito/mockito-core
32+
mockitoVersion = "5.15.2" # https://mvnrepository.com/artifact/org.mockito/mockito-core
3333

3434
[libraries]
3535
bouncyCastle = { module = "org.bouncycastle:bcprov-jdk18on", version.ref = "bouncyCastle" }

javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_020_friends/SampleFriends.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import in.dragonbra.javasteam.steam.handlers.steamfriends.SteamFriends;
88
import in.dragonbra.javasteam.steam.handlers.steamfriends.callback.FriendAddedCallback;
99
import in.dragonbra.javasteam.steam.handlers.steamfriends.callback.FriendsListCallback;
10-
import in.dragonbra.javasteam.steam.handlers.steamfriends.callback.PersonaStatesCallback;
10+
import in.dragonbra.javasteam.steam.handlers.steamfriends.callback.PersonaStateCallback;
1111
import in.dragonbra.javasteam.steam.handlers.steamuser.LogOnDetails;
1212
import in.dragonbra.javasteam.steam.handlers.steamuser.SteamUser;
1313
import in.dragonbra.javasteam.steam.handlers.steamuser.callback.AccountInfoCallback;
@@ -88,7 +88,7 @@ public void run() {
8888

8989
manager.subscribe(AccountInfoCallback.class, this::onAccountInfo);
9090
manager.subscribe(FriendsListCallback.class, this::onFriendList);
91-
manager.subscribe(PersonaStatesCallback.class, this::onPersonaStates);
91+
manager.subscribe(PersonaStateCallback.class, this::onPersonaState);
9292
manager.subscribe(FriendAddedCallback.class, this::onFriendAdded);
9393

9494
isRunning = true;
@@ -203,10 +203,10 @@ private void onFriendAdded(FriendAddedCallback callback) {
203203
System.out.println(callback.getPersonaName() + " is now a friend");
204204
}
205205

206-
private void onPersonaStates(PersonaStatesCallback callback) {
206+
private void onPersonaState(PersonaStateCallback callback) {
207207
// this callback is received when the persona state (friend information) of a friend changes
208208

209209
// for this sample we'll simply display the names of the friends
210-
System.out.println("State change: " + callback.getName() + " " + callback.getState());
210+
System.out.println("State change: " + callback.getName() + " | " + callback.getState() + " | " + callback.getStatusFlags());
211211
}
212212
}

src/main/java/in/dragonbra/javasteam/steam/authentication/AuthSessionDetails.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package `in`.dragonbra.javasteam.steam.authentication
22

33
import `in`.dragonbra.javasteam.enums.EOSType
44
import `in`.dragonbra.javasteam.protobufs.steamclient.SteammessagesAuthSteamclient.EAuthTokenPlatformType
5+
import `in`.dragonbra.javasteam.util.HardwareUtils
56
import `in`.dragonbra.javasteam.util.Utils
67

78
/**
@@ -23,7 +24,8 @@ class AuthSessionDetails {
2324
/**
2425
* Gets or Sets the device name (or user agent). By default, "<DeviceName>(JavaSteam)" will be used.
2526
*/
26-
var deviceFriendlyName: String?
27+
@JvmField
28+
var deviceFriendlyName: String? = HardwareUtils.getMachineName(true)
2729

2830
/**
2931
* Gets or sets the platform type that the login will be performed for.
@@ -62,9 +64,4 @@ class AuthSessionDetails {
6264
*/
6365
@JvmField
6466
var authenticator: IAuthenticator? = null
65-
66-
init {
67-
val machineName = System.getenv("COMPUTERNAME") ?: System.getenv("HOSTNAME")
68-
deviceFriendlyName = "$machineName (JavaSteam)"
69-
}
7067
}

src/main/java/in/dragonbra/javasteam/steam/handlers/steamfriends/SteamFriends.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import `in`.dragonbra.javasteam.steam.handlers.steamfriends.callback.IgnoreFrien
5656
import `in`.dragonbra.javasteam.steam.handlers.steamfriends.callback.NicknameCallback
5757
import `in`.dragonbra.javasteam.steam.handlers.steamfriends.callback.NicknameListCallback
5858
import `in`.dragonbra.javasteam.steam.handlers.steamfriends.callback.PersonaChangeCallback
59-
import `in`.dragonbra.javasteam.steam.handlers.steamfriends.callback.PersonaStatesCallback
59+
import `in`.dragonbra.javasteam.steam.handlers.steamfriends.callback.PersonaStateCallback
6060
import `in`.dragonbra.javasteam.steam.handlers.steamfriends.callback.ProfileInfoCallback
6161
import `in`.dragonbra.javasteam.steam.handlers.steamuser.callback.AccountInfoCallback
6262
import `in`.dragonbra.javasteam.steam.steamclient.callbackmgr.CallbackMsg
@@ -530,7 +530,7 @@ class SteamFriends : ClientMsgHandler() {
530530

531531
/**
532532
* Requests persona state for a list of specified SteamID.
533-
* Results are returned in [PersonaStatesCallback].
533+
* Results are returned in [PersonaStateCallback].
534534
*
535535
* @param steamIdList A list of SteamIDs to request the info of.
536536
* @param requestedInfo The requested info flags. If none specified, this uses [SteamConfiguration.defaultPersonaStateFlags].
@@ -554,7 +554,7 @@ class SteamFriends : ClientMsgHandler() {
554554

555555
/**
556556
* Requests persona state for a specified SteamID.
557-
* Results are returned in [PersonaStatesCallback].
557+
* Results are returned in [PersonaStateCallback].
558558
*
559559
* @param steamID A SteamID to request the info of.
560560
* @param requestedInfo The requested info flags. If none specified, this uses [SteamConfiguration.defaultPersonaStateFlags].
@@ -781,7 +781,7 @@ class SteamFriends : ClientMsgHandler() {
781781
}
782782

783783
perState.body.friendsList.forEach { friend ->
784-
PersonaStatesCallback(friend).also(client::postCallback)
784+
PersonaStateCallback(friend, flags).also(client::postCallback)
785785
}
786786
}
787787

src/main/java/in/dragonbra/javasteam/steam/handlers/steamfriends/callback/PersonaStatesCallback.kt renamed to src/main/java/in/dragonbra/javasteam/steam/handlers/steamfriends/callback/PersonaStateCallback.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ import java.util.*
1414
/**
1515
* This callback is fired in response to someone changing their friend details over the network.
1616
*/
17-
@Suppress("unused")
18-
class PersonaStatesCallback(friend: CMsgClientPersonaState.Friend) : CallbackMsg() {
17+
@Suppress("unused", "CanBePrimaryConstructorProperty")
18+
class PersonaStateCallback(
19+
friend: CMsgClientPersonaState.Friend,
20+
statusFlags: EnumSet<EClientPersonaStateFlag>,
21+
) : CallbackMsg() {
1922

2023
/**
2124
* Gets the status flags. This shows what has changed.
2225
*/
23-
val statusFlags: EnumSet<EClientPersonaStateFlag> = EClientPersonaStateFlag.from(friend.personaStateFlags)
26+
val statusFlags: EnumSet<EClientPersonaStateFlag> = statusFlags
2427

2528
/**
2629
* Gets the friend's [SteamID]

src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.kt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import `in`.dragonbra.javasteam.enums.EUIMode
55
import `in`.dragonbra.javasteam.steam.authentication.AuthSessionDetails
66
import `in`.dragonbra.javasteam.steam.authentication.SteamAuthentication
77
import `in`.dragonbra.javasteam.types.SteamID
8+
import `in`.dragonbra.javasteam.util.HardwareUtils
89
import `in`.dragonbra.javasteam.util.Utils
910

1011
/**
@@ -48,16 +49,8 @@ data class LogOnDetails(
4849
var requestSteam2Ticket: Boolean = false,
4950
var clientOSType: EOSType = Utils.getOSType(),
5051
var clientLanguage: String = "english",
51-
var machineName: String = "",
52+
var machineName: String = HardwareUtils.getMachineName(true),
5253
var chatMode: ChatMode = ChatMode.DEFAULT,
5354
var uiMode: EUIMode = EUIMode.Unknown,
5455
var isSteamDeck: Boolean = false,
55-
) {
56-
init {
57-
var envName = System.getenv("COMPUTERNAME")
58-
if (envName == null) {
59-
envName = System.getenv("HOSTNAME")
60-
}
61-
machineName = "$envName (JavaSteam)"
62-
}
63-
}
56+
)

src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/callback/LoggedOnCallback.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ class LoggedOnCallback : CallbackMsg {
130130
*/
131131
var parentalSettings: ParentalSettings? = null
132132

133+
/**
134+
* Gets the id of the family group a user is joined in.
135+
*/
136+
var familyGroupId: Long = 0L
137+
private set
138+
133139
constructor(packetMsg: IPacketMsg) {
134140
if (!packetMsg.isProto) {
135141
handleNonProtoLogon(packetMsg)
@@ -177,6 +183,8 @@ class LoggedOnCallback : CallbackMsg {
177183
logger.error("Failed to parse parental settings", e)
178184
}
179185
}
186+
187+
familyGroupId = resp.familyGroupId
180188
}
181189

182190
constructor(result: EResult) {

src/main/java/in/dragonbra/javasteam/types/AsyncJobMultiple.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ class AsyncJobMultiple<T : CallbackMsg>(
1818
private val finishCondition: (T) -> Boolean?,
1919
) : AsyncJob(client, jobId) {
2020

21-
class ResultSet(
21+
class ResultSet<T : CallbackMsg>(
2222
var complete: Boolean = false,
2323
var failed: Boolean = false,
24-
var results: List<CallbackMsg> = listOf(),
24+
var results: List<T> = listOf(),
2525
)
2626

27-
private val future = CompletableFuture<ResultSet>()
27+
private val future = CompletableFuture<ResultSet<T>>()
2828

2929
private val results = mutableListOf<T>()
3030

@@ -33,15 +33,15 @@ class AsyncJobMultiple<T : CallbackMsg>(
3333
}
3434

3535
@Deprecated("Use toFuture() instead", ReplaceWith("toFuture()"))
36-
fun toDeferred(): CompletableFuture<ResultSet> = toFuture()
36+
fun toDeferred(): CompletableFuture<ResultSet<T>> = toFuture()
3737

38-
fun toFuture(): CompletableFuture<ResultSet> = future
38+
fun toFuture(): CompletableFuture<ResultSet<T>> = future
3939

40-
suspend fun await(): ResultSet = future.await()
40+
suspend fun await(): ResultSet<T> = future.await()
4141

4242
@Suppress("unused")
4343
@Throws(CancellationException::class)
44-
fun runBlock(): ResultSet = toFuture().get()
44+
fun runBlock(): ResultSet<T> = toFuture().get()
4545

4646
override fun addResult(callback: CallbackMsg): Boolean {
4747
@Suppress("UNCHECKED_CAST")

src/main/java/in/dragonbra/javasteam/util/HardwareUtils.java

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package in.dragonbra.javasteam.util;
22

3+
import org.apache.commons.lang3.StringUtils;
34
import org.apache.commons.lang3.SystemUtils;
45

56
import java.io.*;
67
import java.lang.reflect.Method;
8+
import java.net.InetAddress;
9+
import java.net.UnknownHostException;
710
import java.util.Scanner;
811

912
/**
@@ -191,34 +194,44 @@ private static String readLshal() {
191194
}
192195

193196
public static String getMachineName() {
197+
return getMachineName(false);
198+
}
199+
200+
public static String getMachineName(boolean addTag) {
194201
if (MACHINE_NAME != null) {
195202
return MACHINE_NAME;
196203
}
197204

205+
198206
if (SystemUtils.IS_OS_ANDROID) {
199207
MACHINE_NAME = getAndroidDeviceName();
200208
} else {
201209
MACHINE_NAME = getDeviceName();
202210
}
203211

204-
if (MACHINE_NAME == null || MACHINE_NAME.isEmpty()) {
212+
if (StringUtils.isBlank(MACHINE_NAME)) {
205213
MACHINE_NAME = "Unknown";
206214
}
207215

208-
return MACHINE_NAME;
216+
if (addTag || MACHINE_NAME.contains("Unknown")) {
217+
return MACHINE_NAME + " (JavaSteam)";
218+
} else {
219+
return MACHINE_NAME;
220+
}
209221
}
210222

211223
private static String getDeviceName() {
212-
try {
213-
Process process = Runtime.getRuntime().exec("hostname");
214-
215-
try (var inputStreamReader = new InputStreamReader(process.getInputStream());
216-
var reader = new BufferedReader(inputStreamReader)) {
217-
return reader.readLine().trim();
224+
var hostname = SystemUtils.getHostName();
225+
if (StringUtils.isBlank(hostname)) {
226+
try {
227+
// Last fallback.
228+
hostname = InetAddress.getLocalHost().getHostName();
229+
} catch (UnknownHostException e) {
230+
hostname = null;
218231
}
219-
} catch (IOException e) {
220-
return null;
221232
}
233+
234+
return hostname;
222235
}
223236

224237
private static String getAndroidDeviceName() {

0 commit comments

Comments
 (0)