grantygames

Untitled

Oct 28th, 2015
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.80 KB | None | 0 0
  1. package me.teste.Eventos;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Location;
  7. import org.bukkit.Server;
  8. import org.bukkit.World;
  9. import org.bukkit.configuration.ConfigurationSection;
  10. import org.bukkit.configuration.file.FileConfiguration;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.event.EventHandler;
  13. import org.bukkit.event.Listener;
  14. import org.bukkit.event.entity.EntityDamageByEntityEvent;
  15. import org.bukkit.event.player.PlayerCommandPreprocessEvent;
  16. import org.bukkit.scheduler.BukkitScheduler;
  17.  
  18. import me.teste.Main;
  19. import me.teste.Warps;
  20.  
  21. @SuppressWarnings("unused")
  22. public class Warping
  23. implements Listener
  24. {
  25. Warps warp = Warps.getInstance();
  26. ArrayList<String> teleportando = new ArrayList();
  27.  
  28. @EventHandler
  29. public void warping(PlayerCommandPreprocessEvent e)
  30. {
  31. final String m = e.getMessage().toLowerCase().replace("/", "");
  32. final Player p = e.getPlayer();
  33. if (this.warp.getWarps().getConfigurationSection(m) == null) {
  34. return;
  35. }
  36. e.setCancelled(true);
  37. if ((!p.hasPermission("teste.warp." + m)) || (!p.hasPermission("teste.warp.*")))
  38. {
  39. p.sendMessage(Main.config.getString("Mensagens.Sem-Perm").replaceAll("&", "§").replace("{warp}", m));
  40. return;
  41. }
  42. if (Main.config.getBoolean("Sistema.Delay.Ativar"))
  43. {
  44. if (p.hasPermission("teste.delay.passar"))
  45. {
  46. World w = Bukkit.getServer().getWorld(this.warp.getWarps().getConfigurationSection(m).getString("Mundo"));
  47. double x = this.warp.getWarps().getConfigurationSection(m).getDouble("x");
  48. double y = this.warp.getWarps().getConfigurationSection(m).getDouble("y");
  49. double z = this.warp.getWarps().getConfigurationSection(m).getDouble("z");
  50. float yaw = (float)this.warp.getWarps().getConfigurationSection(m).getDouble("yaw");
  51. float pitch = (float)this.warp.getWarps().getConfigurationSection(m).getDouble("pitch");
  52. p.teleport(new Location(w, x, y, z, yaw, pitch));
  53. p.sendMessage(Main.config.getString("Mensagens.Teleportado").replaceAll("&", "§").replace("{warp}", m));
  54. return;
  55. }
  56. String tempo = Main.config.getString("Sistema.Delay.Tempo");
  57. this.teleportando.add(p.getName());
  58. p.sendMessage(Main.config.getString("Mensagens.Sera-Teleportado").replaceAll("&", "§").replace("{tempo}", tempo));
  59. Bukkit.getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable()
  60. {
  61. public void run()
  62. {
  63. if (Warping.this.teleportando.contains(p.getName()))
  64. {
  65. World w = Bukkit.getServer().getWorld(Warping.this.warp.getWarps().getConfigurationSection(m).getString("Mundo"));
  66. double x = Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("x");
  67. double y = Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("y");
  68. double z = Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("z");
  69. float yaw = (float)Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("yaw");
  70. float pitch = (float)Warping.this.warp.getWarps().getConfigurationSection(m).getDouble("pitch");
  71. p.teleport(new Location(w, x, y, z, yaw, pitch));
  72. Warping.this.teleportando.remove(p.getName());
  73. p.sendMessage(Main.config.getString("Mensagens.Teleportado").replaceAll("&", "§").replace("{warp}", m));
  74. }
  75. }
  76. }, Main.config.getInt("Sistema.Delay.Tempo") * 20);
  77. }
  78. if (!Main.config.getBoolean("Sistema.Delay.Ativar"))
  79. {
  80. World w = Bukkit.getServer().getWorld(this.warp.getWarps().getConfigurationSection(m).getString("Mundo"));
  81. double x = this.warp.getWarps().getConfigurationSection(m).getDouble("x");
  82. double y = this.warp.getWarps().getConfigurationSection(m).getDouble("y");
  83. double z = this.warp.getWarps().getConfigurationSection(m).getDouble("z");
  84. float yaw = (float)this.warp.getWarps().getConfigurationSection(m).getDouble("yaw");
  85. float pitch = (float)this.warp.getWarps().getConfigurationSection(m).getDouble("pitch");
  86. p.teleport(new Location(w, x, y, z, yaw, pitch));
  87. p.sendMessage(Main.config.getString("Mensagens.Teleportado").replaceAll("&", "§").replace("{warp}", m));
  88. return;
  89. }
  90. }
  91.  
  92. @EventHandler
  93. public void levarDano(EntityDamageByEntityEvent e)
  94. {
  95. if (((e.getEntity() instanceof Player)) && ((e.getDamager() instanceof Player)))
  96. {
  97. Player p = (Player)e.getEntity();
  98. if ((Main.config.getBoolean("Sistema.Delay.Cancelar-ao-levar-dano")) &&
  99. (this.teleportando.contains(p.getName())))
  100. {
  101. p.sendMessage(Main.config.getString("Mensagens.Cancelado").replaceAll("&", "§"));
  102. this.teleportando.remove(p.getName());
  103. }
  104. }
  105. }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment