Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.gmail.kumakumapark.arena;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.Sound;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- public class UtilSkillsSystems implements Listener {
- private Arena plugin;
- public UtilSkillsSystems(Arena instance) {
- plugin = instance;
- }
- @EventHandler
- public void Util(PlayerInteractEvent e) {
- Player p = e.getPlayer();
- if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {// このイベントは感圧板を踏んだ時などにも反応してしまうため空気かブロックを右クリックした時のみ処理を実行するようにチェック
- if (e.getItem() != null) { // 手に何も持たない状態でクリックしてもイベントが反応してしまうのでnullチェック
- ItemStack item = e.getItem();
- if (item.getType() == Material.GLOWSTONE_DUST) {
- if (item.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.YELLOW + "Magnetic Impulse")) {
- Player Target = null;
- Location l = p.getLocation();
- for (Player pl : Bukkit.getOnlinePlayers()) {
- if (pl == p) {
- continue;
- }
- if (Target != null) {// Targetがnullかチェック
- p.playSound(l, Sound.SLIME_WALK, 1, 1);
- if (8 >= l.distance(Target.getLocation())) {
- Target = pl;// 取得したプレイヤーの方が小さかったらTargetを新しくそのプレイヤーにする
- }
- } else {
- Target = pl;// Targetがnull(一人目のチェック)の場合はとりあえずTargetの置き換え
- }
- Target.teleport(l);
- Target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 29));
- ItemStack gp1 = new ItemStack(Material.SULPHUR, (int) 30);
- ItemMeta cdgp1 = gp1.getItemMeta();
- cdgp1.setDisplayName(ChatColor.GRAY + "Magnetic Impulse");
- gp1.setItemMeta(cdgp1);
- ItemStack gp2 = new ItemStack(Material.SULPHUR, (int) 20);
- ItemMeta cdgp2 = gp2.getItemMeta();
- cdgp2.setDisplayName(ChatColor.GRAY + "Magnetic Impulse");
- gp2.setItemMeta(cdgp2);
- ItemStack gp3 = new ItemStack(Material.SULPHUR, (int) 10);
- ItemMeta cdgp3 = gp3.getItemMeta();
- cdgp3.setDisplayName(ChatColor.GRAY + "Magnetic Impulse");
- gp3.setItemMeta(cdgp3);
- p.getInventory().setItem(1, gp1);
- ItemStack gs = new ItemStack(Material.GLOWSTONE_DUST);
- ItemMeta cdgs = gs.getItemMeta();
- cdgs.setDisplayName(ChatColor.YELLOW + "Magnetic Impulse");
- gs.setItemMeta(cdgs);
- Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
- public void run() {
- p.getInventory().setItem(1, gp2);
- }
- }, 200L);
- Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
- public void run() {
- p.getInventory().setItem(1, gp3);
- }
- }, 200L);
- Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
- public void run() {
- p.getInventory().setItem(1, gs);
- }
- }, 200L);
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement