Solved How to check if the compass is a lodestone compass?

Discussion in 'Spigot Plugin Development' started by Diaburo, Jun 19, 2021.

  1. I need help to check if the player is holding a lodestone compass, I tried many many things and spent hours but it still don't work. Sorry for bad english.

    Code (Java):
    ItemStack compass = new ItemStack(Material.COMPASS);
                CompassMeta compassMeta = (CompassMeta) compass.getItemMeta();
    Code (Java):
    if (player.getInventory().getItemInMainHand().equals(??????????) {
                    if (player.getWorld().equals(getServer().getWorld("world_nether"))) {
                        player.sendMessage(ChatColor.BLUE + "Compass updated!");
                    else {
                        player.getInventory().setItemInMainHand(new ItemStack(Material.COMPASS));
  2. CompassMeta also has an #isLodestoneTracked() function, which is probably what you are looking for.
    • Like Like x 1
    • Winner Winner x 1
    • Useful Useful x 1
  3. Thank you so much, it works!