Skip to content

Commit

Permalink
fix: 0.2.36.1 - fixed hook to ViaLegacyApi when showing boosbars to 1…
Browse files Browse the repository at this point in the history
….9+ players on 1.8.8, add an option to disable this hook
  • Loading branch information
Misat11 committed Dec 22, 2024
1 parent 326af16 commit fcecde4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-0-2-x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Set the Build number
id: calculated_build_number
env:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'org.screamingsandals.plugin-builder' version '1.0.85' apply false
id 'org.screamingsandals.plugin-builder' version '1.0.87' apply false
id 'me.kcra.takenaka.accessor' version '1.2.0' apply false
id 'com.github.gmazzo.buildconfig' version '3.0.0' apply false
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=0.2.36
version=0.2.36.1

org.gradle.caching=true
org.gradle.parallel=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class BossBar18 implements org.screamingsandals.bedwars.api.boss.BossBar1
public final FakeEntityNMS<?> bossbarEntity;
public final boolean viaActive;
public BossBar viaBossBar; // can't be final
public boolean viaAfterJsonUpdate;

public BossBar18(Location location) {
String backend = Main.getConfigurator().config.getString("bossbar.backend-entity");
Expand All @@ -51,9 +52,12 @@ public BossBar18(Location location) {
bossbarEntity = new BossBarWither(location);
}
boolean viaActive = false;
if (Bukkit.getPluginManager().isPluginEnabled("ViaVersion")) {
if (Main.getConfigurator().config.getBoolean("bossbar.allow-via-hooks") && Bukkit.getPluginManager().isPluginEnabled("ViaVersion")) {
try {
viaBossBar = Via.getAPI().legacyAPI().createLegacyBossBar("", 1, BossColor.PURPLE, BossStyle.SOLID);
String version = Bukkit.getPluginManager().getPlugin("ViaVersion").getDescription().getVersion();
// due to Via now accepting both, many strings including an empty string fails
viaAfterJsonUpdate = Integer.parseInt(version.split("\\.", 2)[0]) >= 5 && !version.equals("5.0.0") && !version.equals("5.0.1");
viaBossBar = Via.getAPI().legacyAPI().createLegacyBossBar(viaAfterJsonUpdate ? "{text: \"\"}" : "", 1, BossColor.PURPLE, BossStyle.SOLID);
viaActive = true;
} catch (Throwable ignored) {
// Too old ViaVersion is installed
Expand All @@ -71,7 +75,7 @@ public String getMessage() {
public void setMessage(String message) {
bossbarEntity.setCustomName(message);
if (viaActive) {
viaBossBar.setTitle(message);
viaBossBar.setTitle(viaAfterJsonUpdate ? "{text: \"" + message.replace("\"", "\\\"") + "\"}" : message);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ public void createFiles() {
checkOrSetConfig(modify, "bossbar.game.style", "SEGMENTED_20");
if (Main.getVersionNumber() <= 108) {
checkOrSetConfig(modify, "bossbar.backend-entity", "dragon");
checkOrSetConfig(modify, "bossbar.allow-via-hooks", true);
}

checkOrSetConfig(modify, "holograms.enabled", true);
Expand Down

0 comments on commit fcecde4

Please sign in to comment.