Guest User

Effect

a guest
Aug 10th, 2014
244
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.topoedits;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.Material;
  9. import org.bukkit.block.Block;
  10. import org.bukkit.event.EventHandler;
  11. import org.bukkit.event.EventPriority;
  12. import org.bukkit.event.Listener;
  13. import org.bukkit.event.block.Action;
  14. import org.bukkit.event.player.PlayerInteractEvent;
  15. import org.bukkit.event.player.PlayerQuitEvent;
  16. import org.bukkit.plugin.java.JavaPlugin;
  17. import static sun.audio.AudioPlayer.player;
  18.  
  19. public class Bombardero extends JavaPlugin implements Listener {
  20.  
  21.     public void onEnable() {
  22.         getServer().getPluginManager().registerEvents(this, this);
  23.     }
  24.  
  25.     public void onDisable() {
  26.     }
  27.         //1
  28.         private Map<String, Long> playerDelays = new HashMap<String, Long>();
  29.     private int castDelay = 120; // 120 Es El Tiempo De Delay
  30.  
  31.     @EventHandler(priority = EventPriority.LOW)
  32.     public void onClick(PlayerInteractEvent event) {
  33.         if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
  34.             if (event.getItem() != null) {
  35.                 if (event.getItem().getType() == Material.GOLD_AXE) {
  36.                     boolean castLightning = true;
  37.                     if (this.playerDelays.containsKey(event.getPlayer().getName())) {
  38.                         long timeRemaining = System.currentTimeMillis() - this.playerDelays.get(event.getPlayer().getName());
  39.                         if (timeRemaining >= 1000 * this.castDelay) {
  40.                             this.playerDelays.remove(event.getPlayer().getName());
  41.                         } else {
  42.                             // You can optionally send them a message. Though, you must make sure to set castLightning to false.
  43.                             int secondsRemaining = (int) (timeRemaining / 1000);
  44.                             event.getPlayer().sendMessage("§c§lPara Usar Esta Hablidad Tienes Que Esperar " + secondsRemaining + "" + (secondsRemaining != 1 ? "s" : "") + " §b§lPara Usar La BOMBA!");
  45.                             castLightning = false;
  46.                         }
  47.                     }
  48.                     if (castLightning) {
  49.                         Block targetBlock = event.getPlayer().getTargetBlock(null, 100);
  50.                         if (targetBlock != null) {
  51.                             event.getPlayer().getWorld().strikeLightning(targetBlock.getLocation());
  52.                             this.playerDelays.put(event.getPlayer().getName(), System.currentTimeMillis());
  53.                         }
  54.                     }
  55.                 }
  56.             }
  57.         }
  58.     }
  59.  
  60.     @EventHandler
  61.     public void onLeave(PlayerQuitEvent event) {
  62.         if (this.playerDelays.containsKey(event.getPlayer().getName()))
  63.             this.playerDelays.remove(event.getPlayer().getName());
  64.     }
  65. }
  66. //42 / 43 TEST
  67. /*event.getPlayer().sendMessage(ChatColor.RED + "Para Usar Esta Hablidad Tienes Que Esperar " + secondsRemaining + "" + (secondsRemaining != 1 ? "s" : "") + " Para Usar La BOMBA!");
  68.                             castLightning = false;*/
RAW Paste Data