Skip to content

Commit

Permalink
Fix patch notes no longer working
Browse files Browse the repository at this point in the history
Thanks mojang
  • Loading branch information
sschr15 committed Feb 6, 2024
1 parent d544297 commit fde809f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import org.quiltmc.community.*
private const val PAGINATOR_TIMEOUT = 60_000L // One minute
private const val CHUNK_SIZE = 10

private const val BASE_URL = "https://launchercontent.mojang.com"
private const val BASE_URL = "https://launchercontent.mojang.com/v2"
private const val JSON_URL = "$BASE_URL/javaPatchNotes.json"

private const val CHECK_DELAY = 60L
Expand Down Expand Up @@ -111,7 +111,7 @@ class MinecraftExtension : Extension() {

respond {
embed {
patchNotes(patch)
patchNotes(patch.get())
}
}
}
Expand Down Expand Up @@ -213,7 +213,7 @@ class MinecraftExtension : Extension() {

currentEntries.entries.forEach {
if (it.version !in knownVersions) {
relayUpdate(it)
relayUpdate(it.get())
knownVersions.add(it.version)
}
}
Expand Down Expand Up @@ -294,7 +294,7 @@ class MinecraftExtension : Extension() {
return result to 0
}

private fun EmbedBuilder.patchNotes(patchNote: PatchNote, maxLength: Int = 1000) {
private suspend fun EmbedBuilder.patchNotes(patchNote: PatchNote, maxLength: Int = 1000) {
val (truncated, remaining) = patchNote.body.formatHTML().truncateMarkdown(maxLength)

title = patchNote.title
Expand Down Expand Up @@ -348,6 +348,9 @@ class MinecraftExtension : Extension() {
}
}

private suspend fun PatchNoteEntry.get() =
client.get("$BASE_URL/$contentPath").body<PatchNote>()

@OptIn(KordPreview::class)
class CheckArguments : Arguments() {
val version by optionalString {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import kotlinx.serialization.Serializable
@Serializable
data class PatchNote(
val body: String,
val contentPath: String,
val id: String,
val image: PatchNoteImage,
val title: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import kotlinx.serialization.Serializable

@Serializable
data class PatchNoteEntries(
val entries: List<PatchNote>,
val entries: List<PatchNoteEntry>,
val version: Int,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

package org.quiltmc.community.modes.quilt.extensions.minecraft

import kotlinx.serialization.Serializable

@Serializable
data class PatchNoteEntry(
val contentPath: String,
val id: String,
val image: PatchNoteImage,
val title: String,
val type: String,
val version: String,
)

0 comments on commit fde809f

Please sign in to comment.