Advertisement
Guest User

Untitled

a guest
Aug 1st, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. package me.frostedtimmy.classes.commands;
  2.  
  3. import java.util.HashMap;
  4.  
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandExecutor;
  7. import org.bukkit.command.CommandSender;
  8. import org.bukkit.entity.Player;
  9.  
  10. import me.frostedtimmy.classes.TimmyClasses;
  11. import me.frostedtimmy.classes.util.Classes;
  12. import net.md_5.bungee.api.ChatColor;
  13.  
  14. public class ClassCommand implements CommandExecutor {
  15.     public HashMap<String, Long> cooldown = new HashMap<String, Long>();
  16.     Classes classes = new Classes();
  17.     TimmyClasses plugin;
  18.    
  19.     public ClassCommand(TimmyClasses plugin) {
  20.         this.plugin = plugin;
  21.     }
  22.  
  23.     @Override
  24.     public boolean onCommand(CommandSender sender, Command cmd, String cmdlabel, String[] args) {
  25.         Player p = (Player) sender;
  26.         int cooldownTime = 86400;
  27.        
  28.         String prefix = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("prefix"));
  29.        
  30.         if (cmd.getName().equalsIgnoreCase("class")) {
  31.            
  32.             if (args.length == 0) {
  33.                
  34.                 if (cooldown.containsKey(p.getName())) {
  35.                     long secondsLeft = ((cooldown.get(p.getName())/1000) + cooldownTime) - (System.currentTimeMillis()/1000);
  36.                    
  37.                     if (secondsLeft>0) {
  38.                         p.sendMessage(prefix + ChatColor.RED + "You must wait another " + ChatColor.AQUA + secondsLeft/3600 + ChatColor.RED + " hours before changing your class again!");
  39.                         return true;
  40.                     }
  41.                 }
  42.                 cooldown.put(p.getName(), System.currentTimeMillis());
  43.                 classes.openGui(p);
  44.             }
  45.            
  46.             if (args[0].equalsIgnoreCase("help")) {
  47.                 p.sendMessage(prefix + ChatColor.GREEN + "Type /class to choose a class.");
  48.                 return true;
  49.             }
  50.         }
  51.         return true;
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement