Skip to content

Commit

Permalink
Bumps dependency version.
Browse files Browse the repository at this point in the history
  • Loading branch information
toxicity188 committed Oct 20, 2024
1 parent 9664f34 commit 7a78f5a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

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

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import kr.toxicity.healthbar.api.healthbar.HealthBarData;
import kr.toxicity.healthbar.api.renderer.TextRenderer;
import kr.toxicity.healthbar.api.text.TextAlign;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;

Expand All @@ -18,7 +19,7 @@ public interface TextLayout extends Layout {
TextAlign align();

@NotNull
Function<HealthBarData, String> pattern();
Function<HealthBarData, Component> pattern();

@NotNull
TextRenderer createRenderer(@NotNull HealthBarData pair);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package kr.toxicity.healthbar.api.placeholder;

import kr.toxicity.healthbar.api.BetterHealthBar;
import kr.toxicity.healthbar.api.healthbar.HealthBarData;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextReplacementConfig;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -184,8 +186,8 @@ public Object value(@NotNull HealthBarData player) {
} else return get.value(list);
}

public static @NotNull Function<HealthBarData, String> toString(@NotNull String pattern) {
var array = new ArrayList<Function<HealthBarData, String>>();
public static @NotNull Function<HealthBarData, Component> toString(@NotNull String pattern) {
var array = new ArrayList<Function<HealthBarData, Component>>();
var sb = new StringBuilder();
var skip = false;
for (char c : pattern.toCharArray()) {
Expand All @@ -208,20 +210,20 @@ public Object value(@NotNull HealthBarData player) {
} else sb.append(c);
}
if (!sb.isEmpty()) {
var string = sb.toString();
var string = Component.text(sb.toString());
array.add(p -> string);
sb.setLength(0);
}
return p -> {
var sb2 = new StringBuilder();
var sb2 = Component.text();
array.forEach(f -> sb2.append(f.apply(p)));
return sb2.toString();
return sb2.build();
};
}

private static @NotNull String legacyAdapt(@NotNull String string) {
private static @NotNull Component legacyAdapt(@NotNull String string) {
var sb1 = new StringBuilder();
var sb2 = new StringBuilder();
var sb2 = Component.text();
var skip = false;
for (char c : string.toCharArray()) {
if (!skip) switch (c) {
Expand All @@ -232,7 +234,7 @@ public Object value(@NotNull HealthBarData player) {
}
case '>' -> {
sb1.append(c);
sb2.append(sb1);
sb2.append(Component.text(sb1.toString()));
sb1.setLength(0);
}
case '\\' -> {
Expand All @@ -243,11 +245,16 @@ public Object value(@NotNull HealthBarData player) {
} else sb1.append(c);
}
if (!sb1.isEmpty()) sb2.append(legacyAdapt0(sb1.toString()));
return sb2.toString();
return sb2.build();
}

private static @NotNull String legacyAdapt0(@NotNull String s) {
return BetterHealthBar.inst().miniMessage().serialize(LegacyComponentSerializer.legacySection().deserialize(s));
private static final TextReplacementConfig TO_MINI_MESSAGE = TextReplacementConfig.builder()
.match(Pattern.compile(".+"))
.replacement((r, b) -> MiniMessage.miniMessage().deserialize(r.group()))
.build();

private static @NotNull Component legacyAdapt0(@NotNull String s) {
return LegacyComponentSerializer.legacySection().deserialize(s).replaceText(TO_MINI_MESSAGE);
}

private static @NotNull String subString(@NotNull String string) {
Expand Down
12 changes: 6 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
`java-library`
kotlin("jvm") version("2.0.20")
kotlin("jvm") version("2.0.21")
id("io.github.goooler.shadow") version("8.1.8")
id("io.papermc.paperweight.userdev") version("1.7.3") apply(false)
id("xyz.jpenilla.run-paper") version("2.3.1")
Expand Down Expand Up @@ -33,7 +33,7 @@ allprojects {
maven("https://repo.alessiodp.com/releases/")
}
dependencies {
implementation("org.bstats:bstats-bukkit:3.0.3")
implementation("org.bstats:bstats-bukkit:3.1.0")
testImplementation(kotlin("test"))
}
tasks {
Expand Down Expand Up @@ -84,7 +84,7 @@ fun getApiDependencyProject(name: String) = project(name).also {
val dist = getApiDependencyProject("dist").spigot()
.dependency("io.lumine:Mythic-Dist:5.7.2")
.dependency("me.clip:placeholderapi:2.11.6")
.dependency("com.github.toxicity188:BetterHud:83ca746ccd")
.dependency("com.github.toxicity188:BetterHud:c3e147bbd3")
.dependency("net.citizensnpcs:citizens-main:2.0.33-SNAPSHOT")
.dependency("net.byteflux:libby-bukkit:1.3.0")
.also {
Expand Down Expand Up @@ -134,10 +134,10 @@ dependencies {
implementation(dist)
implementation(getProject("scheduler:standard").spigot())
implementation(getProject("scheduler:folia").folia())
implementation(getProject("bedrock:geyser").spigot().dependency("org.geysermc.geyser:api:2.2.0-SNAPSHOT"))
implementation(getProject("bedrock:floodgate").spigot().dependency("org.geysermc.floodgate:api:2.2.2-SNAPSHOT"))
implementation(getProject("bedrock:geyser").spigot().dependency("org.geysermc.geyser:api:2.4.2-SNAPSHOT"))
implementation(getProject("bedrock:floodgate").spigot().dependency("org.geysermc.floodgate:api:2.2.3-SNAPSHOT"))
implementation(getProject("modelengine:legacy").spigot().dependency("com.ticxo.modelengine:api:R3.2.0"))
implementation(getProject("modelengine:current").spigot().dependency("com.ticxo.modelengine:ModelEngine:R4.0.6"))
implementation(getProject("modelengine:current").spigot().dependency("com.ticxo.modelengine:ModelEngine:R4.0.7"))
nmsVersions.forEach {
implementation(project(":nms:${it.name}", configuration = "reobf"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class TextLayoutImpl(

override fun charWidth(): Map<Int, Int> = textWidth
override fun align(): TextAlign = align
override fun pattern(): Function<HealthBarData, String> = pattern
override fun pattern(): Function<HealthBarData, Component> = pattern

private class WidthKey(
val key: Key,
Expand Down Expand Up @@ -124,7 +124,7 @@ class TextLayoutImpl(

override fun render(groupCount: Int): PixelComponent {
val key = if (keys.isNotEmpty()) keys[groupCount.coerceAtMost(keys.lastIndex)] else defaultWidth
val target = MINI_MESSAGE.deserialize(pattern.apply(pair))
val target = pattern.apply(pair)
fun length(component: Component): Int {
return ((component as? TextComponent)?.let {
val s = it.style()
Expand Down

0 comments on commit 7a78f5a

Please sign in to comment.