Skip to content

Commit

Permalink
Schedule lobby update of player's inventory after syncing scoreboard …
Browse files Browse the repository at this point in the history
…data

Resolves #38
  • Loading branch information
4Ply committed Dec 25, 2024
1 parent aaf0975 commit 6f2f4f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/kotlin/org/trackedout/AgroNet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ object AgroNet : ModInitializer {
}

if (!serverName.equals("builders", ignoreCase = true)) {
val scoreListener = AgroNetPlayerConnectionListener(scoreApi, claimApi, addDeckToPlayerInventoryAction)
val scoreListener = AgroNetPlayerConnectionListener(scoreApi, claimApi, tasksApi, addDeckToPlayerInventoryAction)
ServerPlayConnectionEvents.JOIN.register(scoreListener)
ServerPlayConnectionEvents.DISCONNECT.register(scoreListener)
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(scoreListener)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import org.trackedout.RunContext.serverName
import org.trackedout.actions.AddDeckToPlayerInventoryAction
import org.trackedout.client.apis.ClaimApi
import org.trackedout.client.apis.ScoreApi
import org.trackedout.client.apis.TasksApi
import org.trackedout.client.models.Score
import org.trackedout.client.models.Task
import org.trackedout.data.BrillianceScoreboardDescription
import org.trackedout.fullRunType
import org.trackedout.runType
Expand All @@ -27,6 +29,7 @@ import java.nio.charset.StandardCharsets
class AgroNetPlayerConnectionListener(
private val scoreApi: ScoreApi,
private val claimApi: ClaimApi,
private val tasksApi: TasksApi,
private val addDeckToPlayerInventoryAction: AddDeckToPlayerInventoryAction,
) : ServerPlayConnectionEvents.Join, ServerPlayConnectionEvents.Disconnect, SimpleSynchronousResourceReloadListener {
private val logger = LoggerFactory.getLogger("ServerPlayConnectionJoin")
Expand Down Expand Up @@ -215,6 +218,17 @@ class AgroNetPlayerConnectionListener(
})

logger.info("Successfully stored ${batchMap.size} objectives for player $playerName")

tasksApi.tasksPost(
Task(
server = "lobby",
type = "update-inventory",
targetPlayer = playerName,
arguments = listOf(),
)
)

logger.info("Created update-inventory task for player $playerName")
} catch (e: Exception) {
e.printStackTrace()
}
Expand Down

0 comments on commit 6f2f4f9

Please sign in to comment.