Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.ekits.listeners;
- import java.util.ArrayList;
- import java.util.List;
- import me.ekits.main.Main;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Material;
- import org.bukkit.entity.Player;
- import org.bukkit.entity.ThrownPotion;
- 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.potion.Potion;
- import org.bukkit.potion.PotionType;
- public class MageHealingWand implements Listener{
- Main plugin;
- public MageHealingWand(Main instance) {
- this.plugin = instance;
- }
- List<Player> cooldown = new ArrayList<Player>();
- @SuppressWarnings("deprecation")
- @EventHandler
- public void Interact(PlayerInteractEvent e) {
- final Player p = e.getPlayer();
- Action action = e.getAction();
- if(p.getItemInHand().getType() != Material.GOLD_HOE) return;
- if(!(cooldown.contains(p)))
- {
- if(action.equals(Action.RIGHT_CLICK_AIR) || action.equals(Action.RIGHT_CLICK_BLOCK)) {
- p.sendMessage(ChatColor.YELLOW + "You have thrown a healing potion!");
- // Create a potion type
- Potion potion = new Potion(PotionType.REGEN, 1);
- // Make it a splash potion
- potion.setSplash(true);
- // Set it to an item stack
- ItemStack itemStack = new ItemStack(Material.POTION);
- potion.apply(itemStack);
- // Spawn the potion
- ThrownPotion thrownPotion = p.launchProjectile(ThrownPotion.class);
- thrownPotion.setItem(itemStack);
- cooldown.add(p);
- Bukkit.getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() {
- public void run() {
- cooldown.remove(p);
- p.sendMessage(ChatColor.GREEN + "You can heal yourself again!");
- }
- }, 250L);
- } else p.sendMessage(ChatColor.RED + "You can't heal yet!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement