Ir para conteúdo
  • 0

[Resolvido] [Duvida] Código


Frogguer

Pergunta

27 respostass a esta questão

Posts Recomendados

sim mais ele essa parte ficou assim new ArrayList();

pq ? 

sei la, vc testou se ta prestando ?

 

GranYT, pode me responder naquele outro skript q eu pedi?

ja lhe respondi, e isso pode contar como free-post ja que vc postou aki M_M

Link para o comentário
Compartilhar em outros sites

tira uma print do codigo ou coloca ele completo aqui.

package me.teste.Eventos;

import java.util.ArrayList;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.scheduler.BukkitScheduler;

import me.teste.Main;
import me.teste.Warps;

@SuppressWarnings("unused")
public class Warping
  implements Listener
{
  Warps warp = Warps.getInstance();
  ArrayList<String> teleportando = new ArrayList();
  
  @EventHandler
  public void warping(PlayerCommandPreprocessEvent e)
  {
    final String m = e.getMessage().toLowerCase().replace("/", "");
    final Player p = e.getPlayer();
    if (this.warp.getWarps().getConfigurationSection(m) == null) {
      return;
    }
    e.setCancelled(true);
    if ((!p.hasPermission("teste.warp." + m)) || (!p.hasPermission("teste.warp.*")))
    {
      p.sendMessage(Main.config.getString("Mensagens.Sem-Perm").replaceAll("&", "§").replace("{warp}", m));
      return;
    }
    if (Main.config.getBoolean("Sistema.Delay.Ativar"))
    {
      if (p.hasPermission("teste.delay.passar"))
      {
        World w = Bukkit.getServer().getWorld(this.warp.getWarps().getConfigurationSection(m).getString("Mundo"));
        double x = this.warp.getWarps().getConfigurationSection(m).getDouble("x");
        double y = this.warp.getWarps().getConfigurationSection(m).getDouble("y");
        double z = this.warp.getWarps().getConfigurationSection(m).getDouble("z");
        float yaw = (float)this.warp.getWarps().getConfigurationSection(m).getDouble("yaw");
        float pitch = (float)this.warp.getWarps().getConfigurationSection(m).getDouble("pitch");
        p.teleport(new Location(w, x, y, z, yaw, pitch));
        p.sendMessage(Main.config.getString("Mensagens.Teleportado").replaceAll("&", "§").replace("{warp}", m));
        return;
      }
      String tempo = Main.config.getString("Sistema.Delay.Tempo");
      this.teleportando.add(p.getName());
      p.sendMessage(Main.config.getString("Mensagens.Sera-Teleportado").replaceAll("&", "§").replace("{tempo}", tempo));
      Bukkit.getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable()
      {
        public void run()
        {
          if (Warping.this.teleportando.contains(p.getName()))
          {
            World w = Bukkit.getServer().getWorld(Warping.this.warp.getWarps().getConfigurationSection(m).getString("Mundo"));
            double x = Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("x");
            double y = Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("y");
            double z = Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("z");
            float yaw = (float)Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("yaw");
            float pitch = (float)Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("pitch");
            p.teleport(new Location(w, x, y, z, yaw, pitch));
            Warping.this.teleportando.remove(p.getName());
            p.sendMessage(Main.config.getString("Mensagens.Teleportado").replaceAll("&", "§").replace("{warp}", m));
          }
        }
      }, Main.config.getInt("Sistema.Delay.Tempo") * 20);
    }
    if (!Main.config.getBoolean("Sistema.Delay.Ativar"))
    {
      World w = Bukkit.getServer().getWorld(this.warp.getWarps().getConfigurationSection(m).getString("Mundo"));
      double x = this.warp.getWarps().getConfigurationSection(m).getDouble("x");
      double y = this.warp.getWarps().getConfigurationSection(m).getDouble("y");
      double z = this.warp.getWarps().getConfigurationSection(m).getDouble("z");
      float yaw = (float)this.warp.getWarps().getConfigurationSection(m).getDouble("yaw");
      float pitch = (float)this.warp.getWarps().getConfigurationSection(m).getDouble("pitch");
      p.teleport(new Location(w, x, y, z, yaw, pitch));
      p.sendMessage(Main.config.getString("Mensagens.Teleportado").replaceAll("&", "§").replace("{warp}", m));
      return;
    }
  }
  
  @EventHandler
  public void levarDano(EntityDamageByEntityEvent e)
  {
    if (((e.getEntity() instanceof Player)) && ((e.getDamager() instanceof Player)))
    {
      Player p = (Player)e.getEntity();
      if ((Main.config.getBoolean("Sistema.Delay.Cancelar-ao-levar-dano")) && 
        (this.teleportando.contains(p.getName())))
      {
        p.sendMessage(Main.config.getString("Mensagens.Cancelado").replaceAll("&", "§"));
        this.teleportando.remove(p.getName());
      }
    }
  }
}
Link para o comentário
Compartilhar em outros sites

Guest HyguiitoDev

No codigo:

p.teleport(new Location(w, x, y, z, yaw, pitch));

Tente colocar:

 Location loc = new Location(w, x, y, z);
 loc.setYaw(yaw);
 loc.setPitch(pitch);
 p.teleport(loc);
Editado por HyguiitoDev
Link para o comentário
Compartilhar em outros sites

O caminho do x,y,z...

      {
        public void run()
        {
          if (Warping.this.teleportando.contains(p.getName()))
          {
            World w = Bukkit.getServer().getWorld(Warping.this.warp.getWarps().getConfigurationSection(m).getString("Mundo"));
            double x = Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("x");
            double y = Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("y");
            double z = Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("z");
            float yaw = (float)Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("yaw");
            float pitch = (float)Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("pitch");
            p.teleport(new Location(w, x, y, z, yaw, pitch));
            Warping.this.teleportando.remove(p.getName());
            p.sendMessage(Main.config.getString("Mensagens.Teleportado").replaceAll("&", "§").replace("{warp}", m));
          }
Link para o comentário
Compartilhar em outros sites

      {
        public void run()
        {
          if (Warping.this.teleportando.contains(p.getName()))
          {
            World w = Bukkit.getServer().getWorld(Warping.this.warp.getWarps().getConfigurationSection(m).getString("Mundo"));
            double x = Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("x");
            double y = Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("y");
            double z = Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("z");
            float yaw = (float)Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("yaw");
            float pitch = (float)Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("pitch");
            p.teleport(new Location(w, x, y, z, yaw, pitch));
            Warping.this.teleportando.remove(p.getName());
            p.sendMessage(Main.config.getString("Mensagens.Teleportado").replaceAll("&", "§").replace("{warp}", m));
          }

 World w = Bukkit.getWorld(getConfig().getString("Warps." + m + ".Mundo"));

e usa no resto desse jeito ai, mais altera....

Link para o comentário
Compartilhar em outros sites

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