Ir para conteúdo
  • 0

[Duvida] Plugin de warp, setar direção


yLR111

Pergunta

6 respostass a esta questão

Posts Recomendados

  • 0

Você salvou usando:
 

  1. settings.getData().set("spawn.pitch", Float.valueOf(p.getLocation().getPitch()));
  2.                 settings.getData().set("spawn.yaw", Float.valueOf(p.getLocation().getYaw()));

 

mas na hora de teleportar você só pegou o x y z.

 

  1.  double x = settings.getData().getDouble("spawn.x");
  2.                 double y = settings.getData().getDouble("spawn.y");
  3.                 double z = settings.getData().getDouble("spawn.z");

 

 

você teria que pegar o pitch e o yaw.

da mesma forma que fez com o x, y e z.

Link para o comentário
Compartilhar em outros sites

  • 0

 

Quero que salvo a direção em que estou olhando

CODIGO

https://pastebin.com/mxB2vVJH

 

Você não está setando o "Pitch" e nem o "Yaw" na Location

 

Tente assim

float Pitch = (float)settings.getData().getDouble("spawn.pitch");
float Yaw = (float)settings.getData().getDouble("spawn.yaw");
Location spawn = new Location(world,x, y, z);
spawn.setPitch(Pitch);
spawn.setYaw(Yaw);
p.teleport(spawn);
Editado por Fredaikis
Link para o comentário
Compartilhar em outros sites

  • 0

Você salvou usando:

 

  1. settings.getData().set("spawn.pitch", Float.valueOf(p.getLocation().getPitch()));
  2.                 settings.getData().set("spawn.yaw", Float.valueOf(p.getLocation().getYaw()));

 

mas na hora de teleportar você só pegou o x y z.

 

  1.  double x = settings.getData().getDouble("spawn.x");
  2.                 double y = settings.getData().getDouble("spawn.y");
  3.                 double z = settings.getData().getDouble("spawn.z");

 

 

você teria que pegar o pitch e o yaw.

da mesma forma que fez com o x, y e z.

como faço pra pegar o pitch e o yaw da config?

Link para o comentário
Compartilhar em outros sites

  • 0
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if(sender instanceof Player) {
            if(command.getName().equalsIgnoreCase("setspawn")) {
                Player p = (Player)sender;
                settings.getData().set("spawn.world", p.getLocation().getWorld().getName());
                settings.getData().set("spawn.x", p.getLocation().getX());
                settings.getData().set("spawn.y", p.getLocation().getY());
                settings.getData().set("spawn.z", p.getLocation().getZ());
                settings.getData().set("spawn.pitch", p.getLocation().getPitch());
                settings.getData().set("spawn.yaw", p.getLocation().getYaw());
                settings.saveData();
                p.sendMessage("§aVocê definiu o 'Spawn' com sucesso!");
                return true;
               
            }
            if(command.getName().equalsIgnoreCase("spawn")) {
                if(settings.getData().getConfigurationSection("spawn") == null) {
                    Player p = (Player)sender;
                    p.sendMessage("§cO Spawn ainda não foi definido!");
                    return true;
                }
                Player p = (Player)sender;
                World w = Bukkit.getServer().getWorld(settings.getData().getString("spawn.world"));
                double x = settings.getData().getDouble("spawn.x");
                double y = settings.getData().getDouble("spawn.y");
                double z = settings.getData().getDouble("spawn.z");
	        float pitch = (float) settings.getData().getDouble("spawn.pitch");
		float yaw = (float) settings.getData().getDouble("spawn.yaw");

		p.teleport(new Location(w, x, y, z, yaw, pitch));
                p.sendMessage("§aBem-vindo ao spawn");
            }

 Você pega o yaw e pitch e põe na localização.

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...