Skip to content

Commit

Permalink
feat: port allow-via-hooks and #552 player death cancelled support
Browse files Browse the repository at this point in the history
  • Loading branch information
Misat11 committed Dec 29, 2024
1 parent ba31f5c commit 321cfc1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 321cfc1

Please sign in to comment.