Muloo Postado Agosto 31, 2017 Denunciar Postado Agosto 31, 2017 Olá galera, gostaria de pedir a ajuda de vocês para pegar o jogador que estou olhando, sei que tenho que usar PlayerMoveEvent mas não faço a menor ideia de como ;-;
VictorHeaven Postado Agosto 31, 2017 Denunciar Postado Agosto 31, 2017 Obrigado, mais eu gostaria de fazer um plugin sem o uso de APIs Tenta isso ai então, eu uso esse método @SuppressWarnings({ "unused" }) public <T extends Player> T getTarget(final Player entity, final Iterable<T> entities) { if (entity == null) { return null; } T target = null; final double threshold = 1.0; for (final T other : entities) { final Vector n = other.getLocation().toVector().subtract(entity.getLocation().toVector()); if (entity.getLocation().getDirection().normalize().crossProduct(n).lengthSquared() < 1.0 && n.normalize().dot(entity.getLocation().getDirection().normalize()) >= 0.0) { if (target == null || target.getLocation().distanceSquared(entity.getLocation()) > other.getLocation().distanceSquared(entity.getLocation())) { target = other; } // aqui é o código! } } return target; } public Player getTargetPlayer(final Player player) { return this.getTarget(player, (Iterable<Player>) player.getWorld().getPlayers()); } @EventHandler public void PlayerMoveEvent(final PlayerMoveEvent e) { final Player p = e.getPlayer(); this.getTargetPlayer(p); } 1
VictorHeaven Postado Agosto 31, 2017 Denunciar Postado Agosto 31, 2017 Caso queira facilitar, use a API do Alex, ele fez um evento exclusivamente para isso! http://gamersboard.com.br/topic/45730-freedev-tintanewevents-api-para-desenvolvimento-novos-eventos/
Muloo Postado Agosto 31, 2017 Autor Denunciar Postado Agosto 31, 2017 Caso queira facilitar, use a API do Alex, ele fez um evento exclusivamente para isso! http://gamersboard.com.br/topic/45730-freedev-tintanewevents-api-para-desenvolvimento-novos-eventos/ Obrigado, mais eu gostaria de fazer um plugin sem o uso de APIs
n00bmobile Postado Agosto 31, 2017 Denunciar Postado Agosto 31, 2017 (editado) Tenta isso ai então, eu uso esse método @SuppressWarnings({ "unused" }) public <T extends Player> T getTarget(final Player entity, final Iterable<T> entities) { if (entity == null) { return null; } T target = null; final double threshold = 1.0; for (final T other : entities) { final Vector n = other.getLocation().toVector().subtract(entity.getLocation().toVector()); if (entity.getLocation().getDirection().normalize().crossProduct(n).lengthSquared() < 1.0 && n.normalize().dot(entity.getLocation().getDirection().normalize()) >= 0.0) { if (target == null || target.getLocation().distanceSquared(entity.getLocation()) > other.getLocation().distanceSquared(entity.getLocation())) { target = other; } // aqui é o código! } } return target; } public Player getTargetPlayer(final Player player) { return this.getTarget(player, (Iterable<Player>) player.getWorld().getPlayers()); } @EventHandler public void PlayerMoveEvent(final PlayerMoveEvent e) { final Player p = e.getPlayer(); this.getTargetPlayer(p); } Recomendo fazer um sistema de cooldown,se não pode lagar. Editado Agosto 31, 2017 por n00bmobile
Muloo Postado Agosto 31, 2017 Autor Denunciar Postado Agosto 31, 2017 Tenta isso ai então, eu uso esse método @SuppressWarnings({ "unused" }) public <T extends Player> T getTarget(final Player entity, final Iterable<T> entities) { if (entity == null) { return null; } T target = null; final double threshold = 1.0; for (final T other : entities) { final Vector n = other.getLocation().toVector().subtract(entity.getLocation().toVector()); if (entity.getLocation().getDirection().normalize().crossProduct(n).lengthSquared() < 1.0 && n.normalize().dot(entity.getLocation().getDirection().normalize()) >= 0.0) { if (target == null || target.getLocation().distanceSquared(entity.getLocation()) > other.getLocation().distanceSquared(entity.getLocation())) { target = other; } // aqui é o código! } } return target; } public Player getTargetPlayer(final Player player) { return this.getTarget(player, (Iterable<Player>) player.getWorld().getPlayers()); } @EventHandler public void PlayerMoveEvent(final PlayerMoveEvent e) { final Player p = e.getPlayer(); this.getTargetPlayer(p); } Obrigado
jeta Postado Agosto 31, 2017 Denunciar Postado Agosto 31, 2017 Sua dúvida foi marcada como [Resolvido] e movido à área de dúvidas resolvidas. Atenciosamente, Gamer's Board
Pergunta
Muloo
Olá galera, gostaria de pedir a ajuda de vocês para pegar o jogador que estou olhando, sei que tenho que usar PlayerMoveEvent mas não faço a menor ideia de como ;-;
6 respostass a esta questão
Posts Recomendados