Guest User

Example - Cooldown Manager v1.1

a guest
Aug 12th, 2014
241
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Sys extends JavaPlugin{
  2.     Cooldown cd;
  3.     public void onEnable(){
  4.         //Cooldown Manager with automatic Cooldown Management for Command + permanent Cache Mode
  5.         cd = new Cooldown(this, true, true, 5, "s");
  6.         cd.addCommand("hello", "bye");
  7.     }
  8.    
  9.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
  10.        
  11.         if(label.equalsIgnoreCase("hello")){
  12.             if(args.length == 1){
  13.                     sender.sendMessage("Hi "  + args[0] + "!");
  14.                 }else{
  15.                     sender.sendMessage("Hi!");
  16.                 }
  17.             }else{
  18.                 sender.sendMessage("Hi!");
  19.             }
  20.         }
  21.        
  22.         if(label.equalsIgnoreCase("bye")){
  23.             if(args.length == 1){
  24.                 sender.sendMessage("Bye "  + args[0] + "!");
  25.             }else{
  26.                 sender.sendMessage("Bye!");
  27.             }
  28.         }
  29.  
  30.         if(label.equalsIgnoreCase("doihavecooldown")){
  31.            
  32.             if(cd.hasCooldown((Player)sender)){
  33.             String cdText = cd.returnCooldown((Player)sender);
  34.             sender.sendMessage("Yes, you have a cooldown!");
  35.             sender.sendMessage("Time Left: " + cdText);
  36.             }else{
  37.             sender.sendMessage("Sir, you don't have a cooldown!");
  38.             sender.sendMessage("Let me add one for five seconds...");
  39.             cd.activateCooldown((Player)sender, 5, "s");
  40.             }
  41.  
  42.         }
  43.  
  44.         if(label.equalsIgnoreCase("doesmycommandhavecooldown")){
  45.            
  46.             if(cd.hasCooldown((Player)sender, "doesmycommandhavecooldown")){
  47.             String cdText = cd.returnCooldown((Player)sender, "doesmycommandhavecooldown");
  48.             sender.sendMessage("Yes, your command has a cooldown!");
  49.             sender.sendMessage("Time Left: " + cdText);
  50.             }else{
  51.             sender.sendMessage("Sir, your command does not have a cooldown!");
  52.             sender.sendMessage("Let me add one for five seconds...");
  53.             cd.activateCooldown((Player)sender, "doesmycommandhavecooldown", 5, "s");
  54.             }
  55.  
  56.         }
  57.         return false;
  58.     }
  59. }
RAW Paste Data