Skip to content

Commit c293a5d

Browse files
committed
feat: add legacy format support to fake_message feature
1 parent 5987299 commit c293a5d

File tree

10 files changed

+44
-15
lines changed

10 files changed

+44
-15
lines changed

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import java.net.URL
77

88
plugins {
99
java
10-
kotlin("jvm") version "2.0.21"
10+
kotlin("jvm") version "2.1.0"
1111
`maven-publish`
1212
id("io.papermc.hangar-publish-plugin") version "0.1.2"
1313
id("com.modrinth.minotaur") version "2.8.7"
@@ -70,7 +70,7 @@ allprojects {
7070
group = findProperty("group")!! as String
7171
version = findProperty("version")!! as String
7272

73-
plugins.apply("java-library")
73+
plugins.apply("java")
7474
plugins.apply("maven-publish")
7575
plugins.apply("kotlin")
7676
plugins.apply("org.sayandev.stickynote.project")

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

sayanvanish-bukkit/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ tasks {
5757
hangar("ViaVersion", "5.0.4-SNAPSHOT+548")
5858
hangar("PlaceholderAPI", "2.11.6")
5959
url("https://cdn.modrinth.com/data/qvdtDX3s/versions/TD9kTO2n/multiverse-inventories-4.2.7-pre.jar")
60+
url("https://github.com/SkinsRestorer/SkinsRestorer/releases/download/15.5.1/SkinsRestorer.jar")
6061
url("https://cdn.modrinth.com/data/3wmN97b8/versions/ehwU9G3y/multiverse-core-4.3.15-pre.2.jar")
6162
url("https://cdn.modrinth.com/data/16vhQOQN/versions/g55TGTXG/minimotd-bukkit-2.1.4.jar")
6263
// url("https://github.com/NEZNAMY/TAB/releases/download/4.1.6/TAB.v4.1.6.jar")

sayanvanish-bukkit/src/main/kotlin/org/sayandev/sayanvanish/bukkit/feature/features/FeatureFakeMessage.kt

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.sayandev.sayanvanish.bukkit.feature.features
22

33
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder
4+
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
45
import org.bukkit.event.EventHandler
56
import org.bukkit.event.EventPriority
67
import org.bukkit.event.player.PlayerJoinEvent
@@ -14,7 +15,9 @@ import org.sayandev.sayanvanish.bukkit.api.event.BukkitUserVanishEvent
1415
import org.sayandev.sayanvanish.bukkit.feature.ListenedFeature
1516
import org.sayandev.sayanvanish.bukkit.utils.PlayerUtils.sendComponent
1617
import org.sayandev.sayanvanish.bukkit.utils.PlayerUtils.sendRawComponent
18+
import org.sayandev.stickynote.bukkit.hook.PlaceholderAPIHook
1719
import org.sayandev.stickynote.bukkit.onlinePlayers
20+
import org.sayandev.stickynote.bukkit.utils.AdventureUtils
1821
import org.sayandev.stickynote.bukkit.utils.AdventureUtils.sendComponent
1922
import org.spongepowered.configurate.objectmapping.ConfigSerializable
2023

@@ -25,6 +28,7 @@ class FeatureFakeMessage(
2528
@Configurable val sendFakeQuitMessage: Boolean = false,
2629
@Configurable val fakeJoinMessage: String = "<yellow><player> joined the game",
2730
@Configurable val fakeQuitMessage: String = "<yellow><player> left the game",
31+
@Configurable val useLegacyFormatter: Boolean = false,
2832
@Configurable val disableJoinMessageIfVanished: Boolean = true,
2933
@Configurable val disableQuitMessageIfVanished: Boolean = true,
3034
) : ListenedFeature("fake_message") {
@@ -76,20 +80,38 @@ class FeatureFakeMessage(
7680
if (!event.options.sendMessage) return
7781
if (sendFakeQuitMessage && !event.options.isOnJoin && !event.options.isOnQuit) {
7882
for (player in onlinePlayers) {
79-
player.sendRawComponent(fakeQuitMessage, Placeholder.unparsed("player", user.username))
83+
if (useLegacyFormatter) {
84+
AdventureUtils.audience.player(player).sendMessage(
85+
LegacyComponentSerializer.legacyAmpersand().deserialize(
86+
PlaceholderAPIHook.injectPlaceholders(player, fakeQuitMessage)
87+
.replace("<player>", user.username)
88+
)
89+
)
90+
} else {
91+
player.sendRawComponent(fakeQuitMessage, Placeholder.unparsed("player", user.username))
92+
}
8093
}
8194
}
8295
}
8396

8497
@EventHandler
8598
private fun onUnVanish(event: BukkitUserUnVanishEvent) {
99+
val user = event.user
86100
if (!event.options.sendMessage) return
87-
if (!isActive(event.user)) return
101+
if (!isActive(user)) return
88102
if (sendFakeJoinMessage && !event.options.isOnJoin && !event.options.isOnQuit) {
89103
for (player in onlinePlayers) {
90-
player.sendRawComponent(fakeJoinMessage, Placeholder.unparsed("player", event.user.username))
104+
if (useLegacyFormatter) {
105+
AdventureUtils.audience.player(player).sendMessage(
106+
LegacyComponentSerializer.legacyAmpersand().deserialize(
107+
PlaceholderAPIHook.injectPlaceholders(player, fakeJoinMessage)
108+
.replace("<player>", user.username)
109+
)
110+
)
111+
} else {
112+
player.sendRawComponent(fakeJoinMessage, Placeholder.unparsed("player", user.username))
113+
}
91114
}
92115
}
93116
}
94-
95117
}

sayanvanish-bukkit/src/main/kotlin/org/sayandev/sayanvanish/bukkit/feature/features/FeatureSilentContainer.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ import org.bukkit.event.player.PlayerInteractEvent
1111
import org.bukkit.event.player.PlayerQuitEvent
1212
import org.bukkit.event.player.PlayerTeleportEvent
1313
import org.bukkit.inventory.CraftingInventory
14-
import org.bukkit.inventory.PlayerInventory
1514
import org.bukkit.util.Vector
1615
import org.sayandev.sayanvanish.api.feature.RegisteredFeature
1716
import org.sayandev.sayanvanish.bukkit.api.SayanVanishBukkitAPI.Companion.user
1817
import org.sayandev.sayanvanish.bukkit.api.event.BukkitUserUnVanishEvent
1918
import org.sayandev.sayanvanish.bukkit.feature.ListenedFeature
2019
import org.sayandev.stickynote.bukkit.runSync
2120
import org.sayandev.stickynote.bukkit.utils.ServerVersion
22-
import org.sayandev.stickynote.bukkit.warn
2321
import org.spongepowered.configurate.objectmapping.ConfigSerializable
2422
import java.util.*
2523

@@ -30,6 +28,16 @@ class FeatureSilentContainer: ListenedFeature("silent_container") {
3028
override var condition: Boolean = ServerVersion.supports(13)
3129
@Transient private val containerPlayersData = mutableMapOf<UUID, ContainerPlayerData>()
3230

31+
/*override fun enable() {
32+
// https://github.com/Syrent/SayanVanish/issues/356
33+
if (hasPlugin("Multiverse-Inventories")) {
34+
warn("`silent_container` feature is not compatible with Multiverse-Inventories. Disabling the feature.")
35+
return
36+
}
37+
38+
super.enable()
39+
}*/
40+
3341
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
3442
private fun onPlayerInteract(event: PlayerInteractEvent) {
3543
val player = event.player

sayanvanish-bukkit/src/main/kotlin/org/sayandev/sayanvanish/bukkit/feature/features/FeatureState.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.sayandev.sayanvanish.bukkit.feature.features
22

3+
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder
34
import org.bukkit.event.EventHandler
45
import org.bukkit.event.EventPriority
56
import org.bukkit.event.player.PlayerJoinEvent
@@ -13,8 +14,6 @@ import org.sayandev.sayanvanish.bukkit.api.SayanVanishBukkitAPI.Companion.getOrC
1314
import org.sayandev.sayanvanish.bukkit.api.SayanVanishBukkitAPI.Companion.user
1415
import org.sayandev.sayanvanish.bukkit.config.language
1516
import org.sayandev.sayanvanish.bukkit.feature.ListenedFeature
16-
import org.sayandev.stickynote.bukkit.utils.AdventureUtils.component
17-
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder
1817
import org.spongepowered.configurate.objectmapping.ConfigSerializable
1918

2019
@RegisteredFeature

sayanvanish-bukkit/src/main/kotlin/org/sayandev/sayanvanish/bukkit/feature/features/FeatureUpdate.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import java.util.concurrent.CompletableFuture
2626
@ConfigSerializable
2727
class FeatureUpdate(
2828
@Configurable val checkEveryXMinutes: Int = 60 * 24,
29-
@Configurable val notifyPermission: String = "sayanvanish.feature.update.notify",
29+
@Configurable val notifyPermission: String = "${plugin.name.lowercase()}.feature.update.notify",
3030
@Configurable val notifyOnJoin: Boolean = true,
3131
@Configurable val notifyForSnapshotBuilds: Boolean = true,
3232
@Configurable val autoUpdateNotification: Boolean = true,

sayanvanish-bukkit/src/main/kotlin/org/sayandev/sayanvanish/bukkit/feature/features/hook/FeatureHookTAB.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class FeatureHookTAB: HookFeature("hook_tab", "TAB") {
2626
}
2727
}
2828

29-
class VanishIntegrationTAB: VanishIntegration(plugin.name) {
29+
private class VanishIntegrationTAB: VanishIntegration(plugin.name) {
3030
override fun isVanished(player: TabPlayer): Boolean {
3131
return SayanVanishBukkitAPI.getInstance().isVanished(player.uniqueId)
3232
}

sayanvanish-proxy/sayanvanish-proxy-velocity/src/main/kotlin/org/sayandev/sayanvanish/velocity/feature/features/hook/FeatureHookVelocitab.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import org.sayandev.sayanvanish.velocity.event.VelocityUserVanishEvent
1616
import org.sayandev.sayanvanish.velocity.feature.HookFeature
1717
import org.sayandev.stickynote.velocity.StickyNote
1818
import org.sayandev.stickynote.velocity.registerListener
19-
import org.sayandev.stickynote.velocity.warn
2019
import org.spongepowered.configurate.objectmapping.ConfigSerializable
2120
import java.util.concurrent.TimeUnit
2221

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pluginManagement {
88
}
99

1010
plugins {
11-
id("org.sayandev.stickynote.settings") version "1.7.131"
11+
id("org.sayandev.stickynote.settings") version "1.8.6"
1212
}
1313

1414
rootProject.name = "SayanVanish"

0 commit comments

Comments
 (0)