Advertisement
Lisenochek

Untitled

Sep 24th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. package com.foxytale.events;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.Location;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.event.EventHandler;
  8. import org.bukkit.event.Listener;
  9. import org.bukkit.event.inventory.InventoryClickEvent;
  10. import org.bukkit.event.player.PlayerMoveEvent;
  11.  
  12. import com.foxytale.lists.Lists;
  13. import com.foxytale.otherAPI.ParticleEffect;
  14.  
  15. public class Handler_fireEffect implements Listener {
  16.  
  17. @EventHandler
  18. public void invClick(InventoryClickEvent e) {
  19.  
  20. Player p = (Player) e.getWhoClicked();
  21.  
  22. if (!e.getInventory().getName().equalsIgnoreCase(ChatColor.GREEN + ChatColor.BOLD.toString() + "Хвосты")) {
  23. return;
  24. }
  25.  
  26. e.setCancelled(true);
  27.  
  28. if (e.getCurrentItem() == null) {
  29. return;
  30. }
  31.  
  32. if (!e.getCurrentItem().hasItemMeta()) {
  33. return;
  34. }
  35.  
  36. if (e.getCurrentItem().getItemMeta().getDisplayName().isEmpty()) {
  37. return;
  38. }
  39.  
  40. if (e.getCurrentItem().getItemMeta().getDisplayName()
  41. .equalsIgnoreCase(ChatColor.GOLD + "Включить хвост: огонь")) {
  42.  
  43. Lists.fireEffect.put(p, p.getLocation());
  44. p.closeInventory();
  45. }
  46. }
  47.  
  48. public static boolean XYZ(Location from, Location to) {
  49. return from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY()
  50. || from.getBlockZ() != to.getBlockZ();
  51. }
  52.  
  53. @EventHandler
  54. public void Effect(PlayerMoveEvent e) {
  55.  
  56. for (Player p : Bukkit.getOnlinePlayers()) {
  57.  
  58. if (Lists.fireEffect.containsKey(p) && XYZ(e.getFrom(), e.getTo())) {
  59.  
  60. Particle();
  61. }
  62. }
  63. }
  64.  
  65. public static void Particle() {
  66.  
  67. for (Player p : Bukkit.getOnlinePlayers()) {
  68.  
  69. if (Lists.fireEffect.containsKey(p)) {
  70.  
  71. ParticleEffect.LAVA.display(0, 0, 0, 0, 0, p.getLocation().add(0, 2, 0), 10);
  72. }
  73. }
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement