Skip to content

Commit

Permalink
chore(bukkit/velocity): use raw message for update notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Syrent committed Nov 29, 2024
1 parent 2ef08cb commit 6ec721f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.sayandev.sayanvanish.bukkit.sayanvanish
import org.sayandev.sayanvanish.api.utils.HangarUtils
import org.sayandev.sayanvanish.api.utils.VersionInfo
import org.sayandev.sayanvanish.bukkit.utils.PlayerUtils.sendComponent
import org.sayandev.sayanvanish.bukkit.utils.PlayerUtils.sendRawComponent
import org.sayandev.stickynote.bukkit.log
import org.sayandev.stickynote.bukkit.plugin
import org.sayandev.stickynote.bukkit.runAsync
Expand All @@ -33,11 +34,9 @@ class FeatureUpdate(
"<green>A new version of <white>SayanVanish</white> is available!",
"<gold> - Latest release: <white><latest_release_name>",
" <yellow>- <gray>Click to download: <blue><click:open_url:'<latest_release_url_paper>'>Paper</click> <gray>|</gray> <aqua><click:open_url:'<latest_release_url_velocity>'>Velocity</click> <gray>|</gray> <blue><click:open_url:'<latest_release_url_waterfall>'>Waterfall</click>",
" <yellow>- <gray>Changelog: <white><latest_release_changelog>",
" <yellow>- <gray><click:open_url:'https://hangar.papermc.io/Syrent/SayanVanish/versions/<latest_release_name>'>Click to see full changelog",
"<gold> - Latest snapshot: <white><latest_snapshot_name>",
" <yellow>- <gray>Click to download: <blue><click:open_url:'<latest_snapshot_url_paper>'>Paper</click> <gray>|</gray> <aqua><click:open_url:'<latest_snapshot_url_velocity>'>Velocity</click> <gray>|</gray> <blue><click:open_url:'<latest_snapshot_url_waterfall>'>Waterfall</click>",
" <yellow>- <gray>Changelog: <white><latest_snapshot_changelog>",
" <yellow>- <gray><click:open_url:'https://hangar.papermc.io/Syrent/SayanVanish/versions/<latest_snapshot_name>'>Click to see full changelog"
),
val updateRequestContent: List<String> = listOf(
Expand Down Expand Up @@ -95,7 +94,7 @@ class FeatureUpdate(
if (!isNewerVersionAvailable(notifyForSnapshotBuilds) || settings.general.proxyMode) return

for (line in updateNotificationContent) {
sender.sendComponent(line
sender.sendRawComponent(line
.replace("<latest_release_name>", latestRelease?.name ?: "Unknown")
.replace("<latest_release_url_paper>", latestRelease?.downloads?.PAPER?.downloadUrl() ?: "https://hangar.papermc.io/Syrent/SayanVanish")
.replace("<latest_release_url_velocity>", latestRelease?.downloads?.VELOCITY?.downloadUrl() ?: "https://hangar.papermc.io/Syrent/SayanVanish")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.sayandev.sayanvanish.velocity.api.SayanVanishVelocityAPI.Companion.us
import org.sayandev.sayanvanish.velocity.feature.ListenedFeature
import org.sayandev.sayanvanish.velocity.sayanvanish
import org.sayandev.sayanvanish.velocity.utils.PlayerUtils.sendComponent
import org.sayandev.sayanvanish.velocity.utils.PlayerUtils.sendRawComponent
import org.sayandev.stickynote.velocity.StickyNote
import org.sayandev.stickynote.velocity.log
import org.sayandev.stickynote.velocity.plugin
Expand All @@ -33,11 +34,9 @@ class FeatureUpdate(
"<green>A new version of <white>SayanVanish Velocity</white> is available!",
"<gold> - Latest release: <white><latest_release_name>",
" <yellow>- <gray>Click to download: <blue><click:open_url:'<latest_release_url_paper>'>Paper</click> <gray>|</gray> <aqua><click:open_url:'<latest_release_url_velocity>'>Velocity</click> <gray>|</gray> <blue><click:open_url:'<latest_release_url_waterfall>'>Waterfall</click>",
" <yellow>- <gray>Changelog: <white><latest_release_changelog>",
" <yellow>- <gray><click:open_url:'https://hangar.papermc.io/Syrent/SayanVanish/versions/<latest_release_name>'>Click to see full changelog",
"<gold> - Latest snapshot: <white><latest_snapshot_name>",
" <yellow>- <gray>Click to download: <blue><click:open_url:'<latest_snapshot_url_paper>'>Paper</click> <gray>|</gray> <aqua><click:open_url:'<latest_snapshot_url_velocity>'>Velocity</click> <gray>|</gray> <blue><click:open_url:'<latest_snapshot_url_waterfall>'>Waterfall</click>",
" <yellow>- <gray>Changelog: <white><latest_snapshot_changelog>",
" <yellow>- <gray><click:open_url:'https://hangar.papermc.io/Syrent/SayanVanish/versions/<latest_snapshot_name>'>Click to see full changelog"
),
val updateRequestContent: List<String> = listOf(
Expand Down Expand Up @@ -94,7 +93,7 @@ class FeatureUpdate(
if (!isNewerVersionAvailable(notifyForSnapshotBuilds)) return

for (line in updateNotificationContent) {
sender.sendComponent(line
sender.sendRawComponent(line
.replace("<latest_release_name>", latestRelease?.name ?: "Unknown")
.replace("<latest_release_url_paper>", latestRelease?.downloads?.PAPER?.downloadUrl() ?: "https://hangar.papermc.io/Syrent/SayanVanish")
.replace("<latest_release_url_velocity>", latestRelease?.downloads?.VELOCITY?.downloadUrl() ?: "https://hangar.papermc.io/Syrent/SayanVanish")
Expand All @@ -105,7 +104,6 @@ class FeatureUpdate(
.replace("<latest_snapshot_url_velocity>", latestSnapshot?.downloads?.VELOCITY?.downloadUrl() ?: "https://hangar.papermc.io/Syrent/SayanVanish")
.replace("<latest_snapshot_url_waterfall>", latestSnapshot?.downloads?.WATERFALL?.downloadUrl() ?: "https://hangar.papermc.io/Syrent/SayanVanish")
.replace("<latest_snapshot_changelog>", shortDescription(latestSnapshot?.description) ?: "Unknown")
.component()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ object PlayerUtils {
content
})
}

fun CommandSource.sendRawComponent(content: String, vararg placeholders: TagResolver) {
this.sendMessage(content.component(*placeholders))
}
}

0 comments on commit 6ec721f

Please sign in to comment.