Solved RespawnAnchorFill Event

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

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

    Nico8k

    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:
    Code:
    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

    Smeary_Subset

    Is the above code using PlayerInteractEvent?
     
  3. Offline

    Nico8k

    Yes it is
     
  4. Offline

    Smeary_Subset

    It works for me:

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

    Output:
    Code:
    [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

    Nico8k

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

    Smeary_Subset

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

Share This Page