Compass help

Discussion in 'Plugin Development' started by krists23, Dec 6, 2013.

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

    krists23

    Hello,

    How would i make that when you right click with compass it tracks nearest person to you and shows with compass where to go.
     
  2. Offline

    LordPyrak

    This *should* work (haven't tested it much)

    Code:
    public class PlayerInteractController implements Listener {
            @EventHandler(priority = EventPriority.MONITOR)
            public void onPlayerInteract(PlayerInteractEvent e) {
                if (e.getPlayer().getItemInHand().getData().getItemType() == Material.COMPASS) {
                    List<Entity> playerList = (List<Entity>) e.getPlayer().getNearbyEntities(1000, 50, 1000);
                    int i=0;
                    int p=playerList.size()-1;
                    while(playerList.get(i).getType()!=EntityType.PLAYER && i<p){i++;}
                    if (i!=p){
                    e.getPlayer().setCompassTarget(playerList.get(i).getLocation());
                    }
                }
            }
        }
     
    
     
Thread Status:
Not open for further replies.

Share This Page