Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment