diff --git a/plugin/bukkit/src/main/java/org/screamingsandals/bedwars/bukkit/BukkitPlatformService.java b/plugin/bukkit/src/main/java/org/screamingsandals/bedwars/bukkit/BukkitPlatformService.java index 24ef3aac1..65bb53bab 100644 --- a/plugin/bukkit/src/main/java/org/screamingsandals/bedwars/bukkit/BukkitPlatformService.java +++ b/plugin/bukkit/src/main/java/org/screamingsandals/bedwars/bukkit/BukkitPlatformService.java @@ -39,19 +39,15 @@ import org.screamingsandals.bedwars.api.game.GameStatus; import org.screamingsandals.bedwars.bukkit.hooks.BukkitBStatsMetrics; import org.screamingsandals.bedwars.bukkit.hooks.PerWorldInventoryCompatibilityFix; -import org.screamingsandals.bedwars.config.MainConfig; import org.screamingsandals.bedwars.game.GameImpl; import org.screamingsandals.bedwars.game.GameManagerImpl; import org.screamingsandals.bedwars.lang.LangKeys; -import org.screamingsandals.lib.Server; import org.screamingsandals.lib.block.BlockPlacement; import org.screamingsandals.lib.block.snapshot.BlockSnapshot; import org.screamingsandals.lib.event.player.PlayerBlockBreakEvent; import org.screamingsandals.lib.event.player.PlayerBlockPlaceEvent; import org.screamingsandals.lib.impl.bukkit.event.player.BukkitPlayerBlockBreakEvent; import org.screamingsandals.lib.impl.bukkit.event.player.BukkitPlayerBlockPlaceEvent; -import org.screamingsandals.lib.impl.bukkit.spectator.bossbar.BukkitBossBar1_8; -import org.screamingsandals.lib.impl.bukkit.spectator.bossbar.GlobalBossBarBackend1_8; import org.screamingsandals.lib.lang.Message; import org.screamingsandals.lib.sender.CommandSender; import org.screamingsandals.lib.spectator.Component; @@ -61,7 +57,6 @@ import org.screamingsandals.lib.tasker.task.TaskBase; import org.screamingsandals.lib.utils.annotations.Service; import org.screamingsandals.lib.utils.annotations.ServiceDependencies; -import org.screamingsandals.lib.utils.annotations.methods.OnPostEnable; import org.screamingsandals.lib.utils.reflect.Reflect; import java.util.Locale; @@ -73,21 +68,6 @@ BukkitBStatsMetrics.class }) public class BukkitPlatformService extends PlatformService { - @OnPostEnable - public void onPostEnable() { - if (!Server.isVersion(1, 9)) { - var backend = MainConfig.getInstance().node("bossbar", "backend-entity").getString("dragon"); - if ("dragon".equalsIgnoreCase(backend)) { - backend = "ender_dragon"; - } - try { - GlobalBossBarBackend1_8.setBackend(BukkitBossBar1_8.Backend.valueOf(backend.toUpperCase(Locale.ROOT))); - } catch (Throwable ignored) { - // invalid value - } - } - } - @Override public void reloadPlugin(@NotNull CommandSender sender) { sender.sendMessage(Message.of(LangKeys.SAFE_RELOAD).defaultPrefix()); diff --git a/plugin/common/src/main/java/org/screamingsandals/bedwars/BedWarsPlugin.java b/plugin/common/src/main/java/org/screamingsandals/bedwars/BedWarsPlugin.java index 37d52f383..816998fd2 100644 --- a/plugin/common/src/main/java/org/screamingsandals/bedwars/BedWarsPlugin.java +++ b/plugin/common/src/main/java/org/screamingsandals/bedwars/BedWarsPlugin.java @@ -401,6 +401,12 @@ public void enable() { Server.getConsoleSender().sendMessage(Component.text("https://www.patreon.com/screamingsandals", Color.WHITE)); HologramManager.setPreferDisplayEntities(MainConfig.getInstance().node("prefer-1-19-4-display-entities").getBoolean()); + if (!Server.isVersion(1, 9)) { + // 1.8.8 boss bars + var backend = MainConfig.getInstance().node("bossbar", "backend-entity").getString("dragon"); + Server.preferEnderDragonBossBar("dragon".equalsIgnoreCase(backend) || "ender_dragon".equalsIgnoreCase(backend)); + Server.enableViaHooksForBossBar(MainConfig.getInstance().node("bossbar", "allow-via-hooks").getBoolean()); + } } @OnDisable diff --git a/plugin/common/src/main/java/org/screamingsandals/bedwars/config/MainConfig.java b/plugin/common/src/main/java/org/screamingsandals/bedwars/config/MainConfig.java index 376ce9528..eb6bc5ea9 100644 --- a/plugin/common/src/main/java/org/screamingsandals/bedwars/config/MainConfig.java +++ b/plugin/common/src/main/java/org/screamingsandals/bedwars/config/MainConfig.java @@ -648,6 +648,7 @@ public void load() { if (!Server.isVersion(1, 9)) { generator.start().key("bossbar", "backend-entity").defValue("dragon"); + generator.start().key("bossbar", "allow-via-hooks").defValue(true); } generator.start() diff --git a/plugin/common/src/main/java/org/screamingsandals/bedwars/listener/PlayerListener.java b/plugin/common/src/main/java/org/screamingsandals/bedwars/listener/PlayerListener.java index cb0c01a8e..8de764f20 100644 --- a/plugin/common/src/main/java/org/screamingsandals/bedwars/listener/PlayerListener.java +++ b/plugin/common/src/main/java/org/screamingsandals/bedwars/listener/PlayerListener.java @@ -88,6 +88,10 @@ public class PlayerListener { @OnEvent(order = EventExecutionOrder.LAST) public void onPlayerDeath(PlayerDeathEvent event) { + if (event.cancelled()) { + return; + } + final var victim = event.player(); // TODO: check for cancellation state if possible (need adjustments in slib)