Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. package com.gmail.kumakumapark.arena;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.Location;
  6. import org.bukkit.Material;
  7. import org.bukkit.Sound;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.event.block.Action;
  12. import org.bukkit.event.player.PlayerInteractEvent;
  13. import org.bukkit.inventory.ItemStack;
  14. import org.bukkit.inventory.meta.ItemMeta;
  15. import org.bukkit.potion.PotionEffect;
  16. import org.bukkit.potion.PotionEffectType;
  17.  
  18. public class UtilSkillsSystems implements Listener {
  19. private Arena plugin;
  20.  
  21. public UtilSkillsSystems(Arena instance) {
  22. plugin = instance;
  23. }
  24.  
  25. @EventHandler
  26. public void Util(PlayerInteractEvent e) {
  27. Player p = e.getPlayer();
  28. if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {// このイベントは感圧板を踏んだ時などにも反応してしまうため空気かブロックを右クリックした時のみ処理を実行するようにチェック
  29. if (e.getItem() != null) { // 手に何も持たない状態でクリックしてもイベントが反応してしまうのでnullチェック
  30. ItemStack item = e.getItem();
  31. if (item.getType() == Material.GLOWSTONE_DUST) {
  32. if (item.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.YELLOW + "Magnetic Impulse")) {
  33. Player Target = null;
  34. Location l = p.getLocation();
  35. for (Player pl : Bukkit.getOnlinePlayers()) {
  36. if (pl == p) {
  37. continue;
  38. }
  39. if (Target != null) {// Targetがnullかチェック
  40. p.playSound(l, Sound.SLIME_WALK, 1, 1);
  41. if (8 >= l.distance(Target.getLocation())) {
  42. Target = pl;// 取得したプレイヤーの方が小さかったらTargetを新しくそのプレイヤーにする
  43.  
  44. }
  45. } else {
  46. Target = pl;// Targetがnull(一人目のチェック)の場合はとりあえずTargetの置き換え
  47. }
  48. Target.teleport(l);
  49. Target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 29));
  50. ItemStack gp1 = new ItemStack(Material.SULPHUR, (int) 30);
  51. ItemMeta cdgp1 = gp1.getItemMeta();
  52. cdgp1.setDisplayName(ChatColor.GRAY + "Magnetic Impulse");
  53. gp1.setItemMeta(cdgp1);
  54. ItemStack gp2 = new ItemStack(Material.SULPHUR, (int) 20);
  55. ItemMeta cdgp2 = gp2.getItemMeta();
  56. cdgp2.setDisplayName(ChatColor.GRAY + "Magnetic Impulse");
  57. gp2.setItemMeta(cdgp2);
  58. ItemStack gp3 = new ItemStack(Material.SULPHUR, (int) 10);
  59. ItemMeta cdgp3 = gp3.getItemMeta();
  60. cdgp3.setDisplayName(ChatColor.GRAY + "Magnetic Impulse");
  61. gp3.setItemMeta(cdgp3);
  62. p.getInventory().setItem(1, gp1);
  63. ItemStack gs = new ItemStack(Material.GLOWSTONE_DUST);
  64. ItemMeta cdgs = gs.getItemMeta();
  65. cdgs.setDisplayName(ChatColor.YELLOW + "Magnetic Impulse");
  66. gs.setItemMeta(cdgs);
  67. Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
  68. public void run() {
  69. p.getInventory().setItem(1, gp2);
  70.  
  71. }
  72. }, 200L);
  73. Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
  74. public void run() {
  75. p.getInventory().setItem(1, gp3);
  76.  
  77. }
  78. }, 200L);
  79. Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
  80. public void run() {
  81. p.getInventory().setItem(1, gs);
  82.  
  83. }
  84. }, 200L);
  85.  
  86. }
  87.  
  88. }
  89. }
  90. }
  91. }
  92. }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement