Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.02 KB | None | 0 0
  1. package it.mr_replete.permission.perm.test;
  2.  
  3.  
  4.  
  5. import java.util.HashMap;
  6.  
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.Material;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.event.EventHandler;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.event.block.Action;
  13. import org.bukkit.event.player.PlayerInteractEvent;
  14.  
  15. import it.mr_replete.permission.PermissionCore;
  16.  
  17.  
  18.  
  19.  
  20. public class EnderPearlCD implements Listener {
  21.    
  22.  
  23.     public static HashMap<String, Integer> pearl = new HashMap<String, Integer>();
  24.    
  25.  
  26.  
  27.    
  28.  
  29.     private int taskId6665;
  30.     int countdown6 = 16;
  31.  
  32.     public void runcd(Player p){
  33.         taskId6665 = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(PermissionCore.getInstance(), new Runnable() {
  34.             public void run() {
  35.                
  36.                 if (countdown6 == 0){
  37.  
  38.                     pearl.put(p.getName(), 0);
  39.                     pearl.remove(p.getName());
  40.                     p.sendMessage("§cEnderpearl cooldown expired");
  41.                     Bukkit.getServer().getScheduler().cancelTask(taskId6665);
  42.                     countdown6 = 16;
  43.  
  44.                     return;
  45.                 }
  46.                 countdown6--;
  47.                
  48.                
  49.                 if (countdown6 == 15){
  50.                     pearl.put(p.getName(), 15);
  51.                 }
  52.                 if (countdown6 == 14){
  53.                     pearl.put(p.getName(), 14);
  54.                
  55.            
  56.                    
  57.                    
  58.                 }
  59.                 if (countdown6 == 13){
  60.                     pearl.put(p.getName(), 13);
  61.                    
  62.                
  63.                
  64.        
  65.                
  66.                 }
  67.                 if (countdown6 == 12){
  68.                     pearl.put(p.getName(), 12);
  69.                    
  70.                    
  71.                
  72.                
  73.                 }
  74.                 if (countdown6 == 11){
  75.                     pearl.put(p.getName(), 11);
  76.                
  77.                
  78.                 }
  79.                 if (countdown6 == 10){
  80.                     pearl.put(p.getName(), 10);
  81.                
  82.                
  83.                 }
  84.                 if (countdown6 == 9){
  85.                     pearl.put(p.getName(), 9);
  86.                
  87.            
  88.                
  89.                 }
  90.                 if (countdown6 == 8){
  91.                     pearl.put(p.getName(), 8);
  92.                    
  93.                 }
  94.                 if (countdown6 == 7){
  95.                     pearl.put(p.getName(), 7);
  96.                
  97.                
  98.                 }
  99.                 if (countdown6 == 6){
  100.                     pearl.put(p.getName(), 6);
  101.        
  102.                 }
  103.                 if (countdown6 == 5){
  104.                     pearl.put(p.getName(), 5);
  105.                
  106.                
  107.                 }
  108.                 if (countdown6 == 4){
  109.                     pearl.put(p.getName(), 4);
  110.                
  111.                    
  112.                
  113.                 }
  114.                 if (countdown6 == 3){
  115.                     pearl.put(p.getName(), 3);
  116.                
  117.                    
  118.                 }
  119.                 if (countdown6 == 2){
  120.                     p.updateInventory();
  121.                     pearl.put(p.getName(), 2);
  122.                    
  123.  
  124.                 }
  125.                 if (countdown6 == 1){
  126.                     p.updateInventory();
  127.                     pearl.put(p.getName(), 1);
  128.  
  129.                 }
  130.                
  131.                
  132.                
  133.            
  134.            
  135.        
  136.             }
  137.         }
  138.             , 0L, 20L);
  139.     }
  140.    
  141.    
  142.  
  143. @SuppressWarnings("static-access")
  144. @EventHandler
  145. public void onright(PlayerInteractEvent e){
  146.     final Player p = e.getPlayer();
  147.    
  148.     if (!p.getItemInHand().getType().equals(Material.ENDER_PEARL)){
  149.         return;
  150.     }
  151.    
  152.     if ((e.getAction().equals(Action.RIGHT_CLICK_AIR)) || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK))) {
  153.        
  154.        
  155.         if (!this.pearl.containsKey(p.getName())){
  156.             runcd(p);
  157.             return;
  158.         }
  159.        
  160.         else {
  161.             int countdown2 = this.pearl.get(p.getName());
  162.             if (countdown2 != 0){
  163.                 p.sendMessage("§cYou have to wait " + countdown6 + " seconds!");
  164.                 e.setCancelled(true);
  165.            
  166.             }
  167.         }
  168.     }
  169.        
  170.  
  171.            
  172.        
  173.    
  174.            
  175.            
  176.        
  177.    
  178.     }
  179.        
  180.        
  181.    
  182.        
  183.    
  184. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement