Solved RespawnAnchorFill Event

Discussion in 'Plugin Development' started by Nico8k, Nov 3, 2022.

Thread Status:
Not open for further replies.
  1. Offline


    Hey, I am trying to find out if a player is filling a respawn anchor.
    I tried to find an anchor fill event but there just seems to be none
    I also tried to get the player target block like this:
    Player player = e.getPlayer();
    HashSet<Byte> nullHashSet = null;
    Block block = player.getTargetBlock((Set<Material>) null, 100);
    Location bl = block.getLocation();
    player.sendMessage(bl.getBlock().getType() + "");
    And it kinda works on everything except the anchor. Everytime I press on it it just returns Air.

    My server and my plugin are both on 1.19.2

    Would be glad if anyone could help me with this!
  2. Offline


    Is the above code using PlayerInteractEvent?
  3. Offline


    Yes it is
  4. Offline


    It works for me:

        private void onPlayerInteract(PlayerInteractEvent event) {
            Bukkit.getLogger().info(event.getPlayer().getTargetBlock(null, 100).getType().name());

    [12:52:18 INFO]: RESPAWN_ANCHOR
    Instead of casting null to Set<Material>, just put null. I tried both ways and both of them worked though.
  5. Offline


    I just found out that my pom.xml didnt use the newest version of minecraft. Sorry for the inconvenience lol
  6. Offline


    No worries! Go ahead and mark thread as solved :)
Thread Status:
Not open for further replies.

Share This Page