diff --git a/plugin/src/main/java/io/github/pronze/sba/game/InvisiblePlayerImpl.java b/plugin/src/main/java/io/github/pronze/sba/game/InvisiblePlayerImpl.java index c911f1e8..e1409706 100644 --- a/plugin/src/main/java/io/github/pronze/sba/game/InvisiblePlayerImpl.java +++ b/plugin/src/main/java/io/github/pronze/sba/game/InvisiblePlayerImpl.java @@ -66,7 +66,11 @@ public void vanish() { .setNameTagVisibility(NameTagVisibility.NEVER)); } final var invisibleScoreboardTeam = holder.getTeamOrRegister(invisTeamName); - invisibleScoreboardTeam.setOption(Option.COLLISION_RULE, OptionStatus.NEVER); + try { + invisibleScoreboardTeam.setOption(Option.COLLISION_RULE, OptionStatus.NEVER); + } catch (Throwable t) { + // 1.8.8 + } holder.getTeamEntry(team.getName()).ifPresent(entry -> { if (entry.hasEntry(hiddenPlayer.getName())) { entry.removeEntry(hiddenPlayer.getName()); @@ -195,7 +199,11 @@ public void showPlayer() { .setNameTagVisibility(NameTagVisibility.NEVER)); } final var invisibleScoreboardTeam = holder.getTeamOrRegister(invisTeamName); - invisibleScoreboardTeam.setOption(Option.COLLISION_RULE, OptionStatus.NEVER); + try { + invisibleScoreboardTeam.setOption(Option.COLLISION_RULE, OptionStatus.NEVER); + } catch (Throwable t) { + // 1.8.8 + } if (invisibleScoreboardTeam.hasEntry(hiddenPlayer.getName())) { invisibleScoreboardTeam.removeEntry(hiddenPlayer.getName()); diff --git a/plugin/src/main/java/io/github/pronze/sba/listener/ExplosionVelocityControlListener.java b/plugin/src/main/java/io/github/pronze/sba/listener/ExplosionVelocityControlListener.java index d2782522..e59c29fc 100644 --- a/plugin/src/main/java/io/github/pronze/sba/listener/ExplosionVelocityControlListener.java +++ b/plugin/src/main/java/io/github/pronze/sba/listener/ExplosionVelocityControlListener.java @@ -19,6 +19,7 @@ import org.bukkit.scheduler.BukkitTask; import org.bukkit.util.Vector; import org.screamingsandals.bedwars.Main; +import org.screamingsandals.lib.impl.bukkit.utils.Version; import org.screamingsandals.lib.utils.annotations.Service; import org.screamingsandals.lib.utils.annotations.methods.OnPostEnable; @@ -70,6 +71,13 @@ public void onExplode(EntityExplodeEvent event) { // final var explodedEntity = event.getDamager(); if (explodedEntity instanceof Explosive) { + if (Version.isVersion(1, 20, 3)) { + var entityKey = explodedEntity.getType().getKey(); + if ("minecraft".equals(entityKey.getNamespace()) && ("wind_charge".equals(entityKey.getKey()) || "breeze_wind_charge".equals(entityKey.getKey()))) { + return; // Ignore wind charges + } + } + final var detectionDistance = SBAConfig.getInstance().node("tnt-fireball-jumping", "detection-distance") .getDouble(5.0D); diff --git a/plugin/src/main/java/io/github/pronze/sba/listener/PlayerListener.java b/plugin/src/main/java/io/github/pronze/sba/listener/PlayerListener.java index e550b46c..c1f1a27f 100644 --- a/plugin/src/main/java/io/github/pronze/sba/listener/PlayerListener.java +++ b/plugin/src/main/java/io/github/pronze/sba/listener/PlayerListener.java @@ -17,6 +17,7 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.NamespacedKey; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; @@ -44,6 +45,7 @@ import org.screamingsandals.bedwars.api.game.GameStatus; import org.screamingsandals.bedwars.game.GamePlayer; import org.screamingsandals.lib.Server; +import org.screamingsandals.lib.impl.bukkit.utils.Version; import org.screamingsandals.lib.player.Players; import org.screamingsandals.lib.utils.annotations.Service; import org.screamingsandals.lib.utils.annotations.methods.OnPostEnable; @@ -378,18 +380,29 @@ public void onPlayerItemConsume(PlayerItemConsumeEvent event) { if (item.getType() == Material.POTION) { final var potionMeta = (PotionMeta) item.getItemMeta(); boolean isInvis = false; - if (potionMeta.getBasePotionData().getType() == PotionType.INVISIBILITY) { - isInvis = true; + if (Version.isVersion(1, 20, 5)) { + var result = (NamespacedKey) Reflect.fastInvokeResulted(potionMeta, "getBasePotionType").fastInvoke("getKey"); + if (result != null && ("invisibility".equals(result.getKey()) || "long_invisibility".equals(result.getKey()))) { + isInvis = true; + } + } else if (Version.isVersion(1, 9)) { + if (potionMeta.getBasePotionData().getType() == PotionType.INVISIBILITY) { + isInvis = true; + } } else { - if (potionMeta.hasCustomEffects()) { - isInvis = potionMeta - .getCustomEffects() - .stream() - .anyMatch(potionEffect -> potionEffect.getType().getName() - .equalsIgnoreCase(PotionEffectType.INVISIBILITY.getName())); + if (org.bukkit.potion.Potion.fromItemStack(item).getType() == PotionType.INVISIBILITY) { + isInvis = true; } } + if (!isInvis && potionMeta.hasCustomEffects()) { + isInvis = potionMeta + .getCustomEffects() + .stream() + .anyMatch(potionEffect -> potionEffect.getType().getName() + .equalsIgnoreCase(PotionEffectType.INVISIBILITY.getName())); + } + if (isInvis) { final var playerGame = Main.getInstance().getGameOfPlayer(player); ArenaManager diff --git a/plugin/src/main/java/io/github/pronze/sba/visuals/LobbyScoreboardManager.java b/plugin/src/main/java/io/github/pronze/sba/visuals/LobbyScoreboardManager.java index 36c36f06..2b025d62 100644 --- a/plugin/src/main/java/io/github/pronze/sba/visuals/LobbyScoreboardManager.java +++ b/plugin/src/main/java/io/github/pronze/sba/visuals/LobbyScoreboardManager.java @@ -25,6 +25,7 @@ import io.github.pronze.sba.SBA; import io.github.pronze.lib.pronzelib.scoreboards.Scoreboard; import io.github.pronze.lib.pronzelib.scoreboards.ScoreboardManager; +import org.screamingsandals.lib.utils.reflect.Reflect; import java.util.*; import java.util.stream.Collectors; @@ -190,7 +191,11 @@ private List process(Player player, Game game, Scoreboard scoreboard) { holder.addTeam(team.getName(), TeamColor.fromApiColor(team.getColor()).chatColor); } final var scoreboardTeam = holder.getTeamOrRegister(team.getName()); - scoreboardTeam.setOption(Option.COLLISION_RULE, OptionStatus.NEVER); + try { + scoreboardTeam.setOption(Option.COLLISION_RULE, OptionStatus.NEVER); + } catch (Throwable t) { + // 1.8.8 + } new HashSet<>(scoreboardTeam.getEntries()) .stream()