Skip to content

Commit

Permalink
Revert "Merge pull request #81 from gabber235/bug/displayname-placeho…
Browse files Browse the repository at this point in the history
…lders"

This reverts commit bd4eba2, reversing
changes made to 17f18ea.
  • Loading branch information
calebneuf committed Oct 17, 2023
1 parent bd4eba2 commit 8fa4d32
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import me.gabber235.typewriter.entry.Query
import me.gabber235.typewriter.entry.entries.CinematicAction
import me.gabber235.typewriter.entry.entries.CinematicEntry
import me.gabber235.typewriter.entry.entries.SpeakerEntry
import me.gabber235.typewriter.extensions.placeholderapi.parsePlaceholders
import me.gabber235.typewriter.interaction.acceptActionBarMessage
import me.gabber235.typewriter.snippets.snippet
import me.gabber235.typewriter.utils.*
Expand Down Expand Up @@ -107,7 +106,7 @@ private fun displayActionBar(player: Player, speakerName: String, text: String,
val padding = " ".repeat(paddingSize)

val component = actionBarFormat.asMiniWithResolvers(
Placeholder.parsed("speaker", speakerName.parsePlaceholders(player)),
Placeholder.parsed("speaker", speakerName),
Placeholder.component("message", message),
Placeholder.unparsed("padding", padding),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class DisplayDialogueCinematicAction(

val text = segment.text.parsePlaceholders(player)

display(player, speaker?.displayName?.parsePlaceholders(player) ?: "", text, displayPercentage)
display(player, speaker?.displayName ?: "", text, displayPercentage)
}

override suspend fun teardown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private fun displaySpokenDialogue(player: Player, speakerName: String, text: Str
)

val component = spokenFormat.asMiniWithResolvers(
Placeholder.parsed("speaker", speakerName.parsePlaceholders(player)),
Placeholder.parsed("speaker", speakerName),
Placeholder.component("message", message),
Placeholder.parsed("padding", spokenPadding),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import me.gabber235.typewriter.entry.Query
import me.gabber235.typewriter.entry.entries.CinematicAction
import me.gabber235.typewriter.entry.entries.CinematicEntry
import me.gabber235.typewriter.entry.entries.SpeakerEntry
import me.gabber235.typewriter.extensions.placeholderapi.parsePlaceholders
import me.gabber235.typewriter.interaction.acceptActionBarMessage
import me.gabber235.typewriter.snippets.snippet
import me.gabber235.typewriter.utils.Icons
Expand Down Expand Up @@ -116,7 +115,7 @@ private fun displaySubTitle(player: Player, speakerName: String, text: String, d
)

val actionBarComponent = subtitleSpeakerFormat.asMiniWithResolvers(
Placeholder.parsed("speaker", speakerName.parsePlaceholders(player)),
Placeholder.parsed("speaker", speakerName),
)

player.showTitle(Title.title(Component.empty(), component, times))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,40 @@ package me.gabber235.typewriter.entries.dialogue.messengers.message
import me.gabber235.typewriter.adapters.Messenger
import me.gabber235.typewriter.adapters.MessengerFilter
import me.gabber235.typewriter.entries.dialogue.MessageDialogueEntry
import me.gabber235.typewriter.entry.dialogue.DialogueMessenger
import me.gabber235.typewriter.entry.dialogue.MessengerState
import me.gabber235.typewriter.entry.dialogue.*
import me.gabber235.typewriter.entry.entries.DialogueEntry
import me.gabber235.typewriter.extensions.placeholderapi.parsePlaceholders
import me.gabber235.typewriter.snippets.snippet
import me.gabber235.typewriter.utils.sendMiniWithResolvers
import me.gabber235.typewriter.utils.*
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder
import org.bukkit.entity.Player

val messageFormat: String by snippet(
"dialogue.message.format",
"\n<gray> [ <bold><speaker></bold><reset><gray> ]\n<reset><white> <message>\n"
"dialogue.message.format",
"\n<gray> [ <bold><speaker></bold><reset><gray> ]\n<reset><white> <message>\n"
)

@Messenger(MessageDialogueEntry::class)
class UniversalMessageDialogueDialogueMessenger(player: Player, entry: MessageDialogueEntry) :
DialogueMessenger<MessageDialogueEntry>(player, entry) {
DialogueMessenger<MessageDialogueEntry>(player, entry) {

companion object : MessengerFilter {
override fun filter(player: Player, entry: DialogueEntry): Boolean = true
}
companion object : MessengerFilter {
override fun filter(player: Player, entry: DialogueEntry): Boolean = true
}

override fun tick(cycle: Int) {
super.tick(cycle)
if (cycle == 0) {
player.sendMessageDialogue(entry.text, entry.speakerDisplayName)
state = MessengerState.FINISHED
}
}
override fun tick(cycle: Int) {
super.tick(cycle)
if (cycle == 0) {
player.sendMessageDialogue(entry.text, entry.speakerDisplayName)
state = MessengerState.FINISHED
}
}
}

fun Player.sendMessageDialogue(text: String, speakerDisplayName: String) {
sendMiniWithResolvers(
messageFormat,
Placeholder.parsed("speaker", speakerDisplayName.parsePlaceholders(player)),
Placeholder.parsed("message", text.parsePlaceholders(player).replace("\n", "\n "))
)
sendMiniWithResolvers(
messageFormat,
Placeholder.parsed("speaker", speakerDisplayName),
Placeholder.parsed("message", text.parsePlaceholders(player).replace("\n", "\n "))
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class JavaOptionDialogueDialogueMessenger(player: Player, entry: OptionDialogueE
}

val message = optionFormat.asMiniWithResolvers(
Placeholder.parsed("speaker", speakerDisplayName.parsePlaceholders(player)),
Placeholder.parsed("speaker", speakerDisplayName),
Placeholder.parsed("text", entry.text.parsePlaceholders(player)),
Placeholder.component("options", formatOptions()),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import me.gabber235.typewriter.entries.dialogue.messengers.spoken.sendSpokenDial
import me.gabber235.typewriter.entry.dialogue.DialogueMessenger
import me.gabber235.typewriter.entry.dialogue.MessengerState
import me.gabber235.typewriter.entry.entries.DialogueEntry
import me.gabber235.typewriter.extensions.placeholderapi.parsePlaceholders
import org.bukkit.entity.Player
import org.bukkit.event.player.PlayerSwapHandItemsEvent

Expand All @@ -24,7 +23,7 @@ class JavaRandomSpokenDialogueDialogueMessenger(player: Player, entry: RandomSpo

override fun init() {
super.init()
speakerDisplayName = entry.speakerDisplayName.parsePlaceholders(player)
speakerDisplayName = entry.speakerDisplayName
text = entry.messages.randomOrNull() ?: ""

listen<PlayerSwapHandItemsEvent> { event ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,24 @@ import me.gabber235.typewriter.adapters.Messenger
import me.gabber235.typewriter.adapters.MessengerFilter
import me.gabber235.typewriter.entries.dialogue.RandomMessageDialogueEntry
import me.gabber235.typewriter.entries.dialogue.messengers.message.sendMessageDialogue
import me.gabber235.typewriter.entry.dialogue.DialogueMessenger
import me.gabber235.typewriter.entry.dialogue.MessengerState
import me.gabber235.typewriter.entry.dialogue.*
import me.gabber235.typewriter.entry.entries.DialogueEntry
import me.gabber235.typewriter.extensions.placeholderapi.parsePlaceholders
import org.bukkit.entity.Player

@Messenger(RandomMessageDialogueEntry::class)
class RandomMessageDialogueDialogueMessenger(player: Player, entry: RandomMessageDialogueEntry) :
DialogueMessenger<RandomMessageDialogueEntry>(player, entry) {
DialogueMessenger<RandomMessageDialogueEntry>(player, entry) {

companion object : MessengerFilter {
override fun filter(player: Player, entry: DialogueEntry): Boolean = true
}
companion object : MessengerFilter {
override fun filter(player: Player, entry: DialogueEntry): Boolean = true
}

override fun tick(cycle: Int) {
super.tick(cycle)
if (cycle == 0) {
val message = entry.messages.randomOrNull() ?: return
player.sendMessageDialogue(message, entry.speakerDisplayName.parsePlaceholders(player))
state = MessengerState.FINISHED
}
}
override fun tick(cycle: Int) {
super.tick(cycle)
if (cycle == 0) {
val message = entry.messages.randomOrNull() ?: return
player.sendMessageDialogue(message, entry.speakerDisplayName)
state = MessengerState.FINISHED
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class JavaSpokenDialogueDialogueMessenger(player: Player, entry: SpokenDialogueE
private var speakerDisplayName = ""
override fun init() {
super.init()
speakerDisplayName = entry.speakerDisplayName.parsePlaceholders(player)
speakerDisplayName = entry.speakerDisplayName

listen<PlayerSwapHandItemsEvent> { event ->
if (event.player.uniqueId != player.uniqueId) return@listen
Expand Down
4 changes: 0 additions & 4 deletions documentation/docs/docs/02-installation-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ The web panel needs two ports to be open. These can be changed, but it does need
default ports are `8080` and `9092`. If you are not able to open these ports, the easiest way is to use typewriter
locally and copying the files in `server/plugins/Typewriter/pages` to your production server.

:::caution
You will get an error if the ports in the config are being used already. Make sure these ports are available by using `netstat -aon | find /i "[port]"`. (Windows only)
:::

To enable the web panel, follow these steps:

1. Open the `server/plugins/Typewriter/config.yml` file.
Expand Down
48 changes: 19 additions & 29 deletions documentation/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions documentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"@docusaurus/core": "^2.4.1",
"@docusaurus/preset-classic": "^2.4.1",
"@mdx-js/react": "^1.6.22",
"@rive-app/react-canvas": "^3.0.57",
"@rive-app/react-canvas": "^3.0.51",
"clsx": "^1.2.1",
"prism-react-renderer": "^1.3.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-player": "^2.13.0",
"react-player": "^2.12.0",
"rive-loader": "file:plugins/rive-loader"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ val centralDependencies = listOf(
"org.jetbrains.kotlin:kotlin-stdlib:1.8.20",
"org.jetbrains.kotlin:kotlin-reflect:1.8.20",
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1",
"com.corundumstudio.socketio:netty-socketio:1.7.19", // Keep this on a lower version as the newer version breaks the ping
)

dependencies {
Expand All @@ -41,7 +42,6 @@ dependencies {
implementation("io.ktor:ktor-server-core-jvm:2.3.4")
implementation("io.ktor:ktor-server-netty-jvm:2.3.4")
implementation("io.insert-koin:koin-core:3.4.0")
implementation("com.corundumstudio.socketio:netty-socketio:1.7.19") // Keep this on a lower version as the newer version breaks the ping

compileOnly("com.github.shynixn.mccoroutine:mccoroutine-bukkit-api:2.11.0")
compileOnly("com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:2.11.0")
Expand Down

0 comments on commit 8fa4d32

Please sign in to comment.