Item Cooldown

Discussion in 'Plugin Development' started by snake4212, Jul 3, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    snake4212

    I am making a plugin where you can use an item like a fire charge and it shoots out a fireball when you right click. It works but spamming it is op so is there a way I could temp make it a different item for like 5 Seconds it becomes dirt for 5 Seconds then goes back.
    Essentially it is a way to cooldown the item for 5 Seconds
    This is my main class
    Code:
    package me.snake4212.MapCrashers;
     
    import me.snake4212.MapCrashers.MapCrashersListener;
     
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class MapCrashersMain extends JavaPlugin{
     
     public void onEnable(){
     getServer().getPluginManager().registerEvents(new MapCrashersListener(), this);
     }
     
     public void onDisable(){
     
     }
     
    }
    
    This is my listener
    Code:
    package me.snake4212.MapCrashers;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Fireball;
    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;
    public class MapCrashersListener implements Listener {
    public MapCrashersListener() {
    }
    @EventHandler
     public void onPowerActivation(PlayerInteractEvent event) {
     Player player = event.getPlayer();
     if (((event.getAction() == Action.RIGHT_CLICK_AIR) || (event.getAction() == Action.RIGHT_CLICK_BLOCK)) && (player.getItemInHand().getEnchantmentLevel(Enchantment.ARROW_FIRE) == 5)) {
     player.launchProjectile(Fireball.class);
     }else {
     event.setCancelled(true);
     }
     }
     
    }
    
     
  2. Offline

    pkt

    just set the item to a stick or something, then use schedulers to set it back later

    T3h Cr33p3r that's an even cooler idea!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  3. Offline

    snake4212

    That seems good problem im stupid and don't know what to do from that lol

    I wish I could understand please add me on skype I will pm u it

    lolk

    -_- nothing but breaking the plugin

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  4. Offline

    AmShaegar

    This is how I do cooldowns. Do not use Runnables, Tasks, Schedulers whatever if not necessary:
     
Thread Status:
Not open for further replies.

Share This Page