Ignore interact events from Spectators

This commit is contained in:
Allink 2023-07-25 17:43:15 +01:00
parent 11c24cff68
commit 9e584069e6
No known key found for this signature in database
2 changed files with 11 additions and 7 deletions

View File

@ -4,6 +4,7 @@ import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
@ -69,6 +70,10 @@ public class InteractBlocker extends FreedomService
private void handleRightClick(PlayerInteractEvent event)
{
final Player player = event.getPlayer();
if (player.getGameMode().equals(GameMode.SPECTATOR)) {
return;
}
final Block clickedBlock = event.getClickedBlock();
if (clickedBlock != null && clickedBlock.getType() == Material.RESPAWN_ANCHOR && !ConfigEntry.ALLOW_RESPAWN_ANCHORS.getBoolean())

View File

@ -13,13 +13,7 @@ import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.shop.ShopItem;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EnderPearl;
@ -100,6 +94,11 @@ public class ItemFun extends FreedomService
{
Player player = event.getPlayer();
if (player.getGameMode().equals(GameMode.SPECTATOR))
{
return;
}
Entity entity = event.getRightClicked();
FPlayer fPlayer = plugin.pl.getPlayer(player);