Skip to content

Commit

Permalink
fix: minor parsing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Feb 6, 2024
1 parent fb8a2f0 commit 9516e4d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/src/main/kotlin/com/mineinabyss/emojy/EmojyHelpers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ fun Component.transformEmoteIDs(player: Player?, insert: Boolean = true, unescap

msg = msg.replaceText(
TextReplacementConfig.builder()
.match(match.value).once()
.replacement(emote.formattedUnicode(insert = false, colorable = colorable, bitmapIndex = bitmapIndex))
.match(emote.baseRegex.pattern).once()
.replacement(emote.formattedUnicode(insert = insert, colorable = colorable, bitmapIndex = bitmapIndex))
.build()
)
}

if (unescape) emote.escapedRegex.findAll(serialized).forEach { match ->
msg = msg.replaceText(
TextReplacementConfig.builder()
.matchLiteral(match.value).once()
.match(emote.escapedRegex.pattern).once()
.replacement(match.value.removePrefix("\\"))
.build()
)
Expand All @@ -111,7 +111,7 @@ fun Component.transformEmoteIDs(player: Player?, insert: Boolean = true, unescap
gif.baseRegex.findAll(serialized).forEach { match ->
msg = msg.replaceText(
TextReplacementConfig.builder()
.match(gif.baseRegex.pattern)
.match(gif.baseRegex.pattern).once()
.replacement(gif.formattedUnicode(insert = insert))
.build()
)
Expand All @@ -120,7 +120,7 @@ fun Component.transformEmoteIDs(player: Player?, insert: Boolean = true, unescap
if (unescape) gif.escapedRegex.findAll(serialized).forEach { match ->
msg = msg.replaceText(
TextReplacementConfig.builder()
.match(gif.escapedRegex.pattern)
.match(gif.escapedRegex.pattern).once()
.replacement(match.value.removePrefix("\\"))
.build()
)
Expand All @@ -132,7 +132,7 @@ fun Component.transformEmoteIDs(player: Player?, insert: Boolean = true, unescap
val spaceRegex = "(?<!\\\\):space_(-?$space+):".toRegex()
msg = msg.replaceText(
TextReplacementConfig.builder()
.match(spaceRegex.pattern)
.match(spaceRegex.pattern).once()
.replacement(spaceComponent(space))
.build()
)
Expand All @@ -141,7 +141,7 @@ fun Component.transformEmoteIDs(player: Player?, insert: Boolean = true, unescap
if (unescape) escapedSpaceRegex.findAll(serialized).forEach { match ->
msg = msg.replaceText(
TextReplacementConfig.builder()
.match(match.value)
.match(match.value).once()
.replacement(match.value.removePrefix("\\"))
.build()
)
Expand Down

0 comments on commit 9516e4d

Please sign in to comment.