Skip to content

Commit

Permalink
Merge pull request #76 from Misat11/fix/misc-fixes
Browse files Browse the repository at this point in the history
fix: misc fixes
  • Loading branch information
boiscljo authored Aug 7, 2024
2 parents f5bee96 + 60216e3 commit 7f4f558
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -190,7 +191,11 @@ private List<String> 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()
Expand Down

0 comments on commit 7f4f558

Please sign in to comment.