Skip to content

Commit

Permalink
Fix friendly villagers can see Spectators
Browse files Browse the repository at this point in the history
  • Loading branch information
MetallicGoat committed May 22, 2023
1 parent aa629c4 commit 3f66253
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class SwordsToolsConfig {
}
)
public static boolean always_sword_chest_enabled = false;
@Config public static boolean always_sword_drop_enabled = true;
@Config public static boolean always_sword_drop_enabled = false;

@Config(
description = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.metallicgoat.tweaksaddon.tweaks.cosmetic;

import de.marcely.bedwars.api.BedwarsAPI;
import de.marcely.bedwars.api.GameAPI;
import de.marcely.bedwars.api.event.arena.RoundEndEvent;
import de.marcely.bedwars.api.event.arena.RoundStartEvent;
import de.marcely.bedwars.api.world.WorldStorage;
Expand Down Expand Up @@ -96,10 +97,14 @@ private void startLooking() {

// Get players in range of villager
final List<Player> visiblePlayers = new ArrayList<>();

for (Player player : hologramEntity.getSeeingPlayers()) {

// Check for same world & within range
if (player.getWorld() != hologramEntity.getWorld().asBukkit() || player.getLocation().distance(hologramEntity.getLocation()) > MainConfig.friendly_villagers_range)
if (player.getWorld() != hologramEntity.getWorld().asBukkit() ||
GameAPI.get().getArenaByPlayer(player) == null ||
GameAPI.get().getSpectatingPlayers().contains(player) ||
player.getLocation().distance(hologramEntity.getLocation()) > MainConfig.friendly_villagers_range)
continue;

// Check if villager can even see player
Expand Down

0 comments on commit 3f66253

Please sign in to comment.