Exempt creative/spectator gamemode from environmental PvP checks (#446)
Also performs visibility check.
This commit is contained in:
parent
0356356edc
commit
9ff369fd62
|
|
@ -23,6 +23,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
|
|
@ -208,8 +209,14 @@ public class BlockEventHandler implements Listener
|
|||
for(int i = 0; i < players.size(); i++)
|
||||
{
|
||||
Player otherPlayer = players.get(i);
|
||||
|
||||
// Ignore players in creative or spectator mode to avoid users from checking if someone is spectating near them
|
||||
if(otherPlayer.getGameMode() == GameMode.CREATIVE || otherPlayer.getGameMode() == GameMode.SPECTATOR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Location location = otherPlayer.getLocation();
|
||||
if(!otherPlayer.equals(player) && location.distanceSquared(block.getLocation()) < 9)
|
||||
if(!otherPlayer.equals(player) && location.distanceSquared(block.getLocation()) < 9 && player.canSee(otherPlayer))
|
||||
{
|
||||
GriefPrevention.sendMessage(player, TextMode.Err, Messages.PlayerTooCloseForFire2);
|
||||
placeEvent.setCancelled(true);
|
||||
|
|
|
|||
|
|
@ -1503,7 +1503,7 @@ class PlayerEventHandler implements Listener
|
|||
{
|
||||
Player otherPlayer = players.get(i);
|
||||
Location location = otherPlayer.getLocation();
|
||||
if(!otherPlayer.equals(player) && otherPlayer.getGameMode() == GameMode.SURVIVAL && block.getY() >= location.getBlockY() - 1 && location.distanceSquared(block.getLocation()) < minLavaDistance * minLavaDistance)
|
||||
if(!otherPlayer.equals(player) && otherPlayer.getGameMode() == GameMode.SURVIVAL && player.canSee(otherPlayer) && block.getY() >= location.getBlockY() - 1 && location.distanceSquared(block.getLocation()) < minLavaDistance * minLavaDistance)
|
||||
{
|
||||
instance.sendMessage(player, TextMode.Err, Messages.NoLavaNearOtherPlayer, "another player");
|
||||
bucketEvent.setCancelled(true);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user