Lexepi

Untitled

Apr 6th, 2017
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. package fr.lexepi.chat.command;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Map;
  5.  
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandExecutor;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10.  
  11. import fr.lexepi.chat.Chat;
  12. import fr.lexepi.chat.gui.Inventory;
  13.  
  14. public class ChatCommand implements CommandExecutor{
  15.  
  16. private Map<String, Long> cooldowns = new HashMap<>();
  17.  
  18. public ChatCommand(Chat chat) {
  19. }
  20.  
  21. String prefix = "§4§l[§cChat§4§l]";
  22.  
  23. @Override
  24. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  25. if(cmd.getName().equalsIgnoreCase("chat")){
  26. if(sender instanceof Player){
  27. Player p = (Player)sender;
  28. if(p.hasPermission("chat.options")){
  29.  
  30. if(cooldowns.containsKey(p.getName())){
  31.  
  32. int seconds = 5;
  33. long timeleft = ((cooldowns.get(p.getName()) / 1000) + seconds) - (System.currentTimeMillis() / 1000);
  34. if(timeleft > 0){
  35. p.sendMessage(prefix+" §4Il te reste §c" + timeleft + "s§4 pour ouvrir cette inventaire !");
  36. return true;
  37. }
  38.  
  39. }
  40.  
  41. cooldowns.put(p.getName(), System.currentTimeMillis());
  42.  
  43. p.sendMessage(prefix+" §aLes options on été ouverte.");
  44. Inventory.OpenInventory(p);
  45. }
  46. }
  47. }
  48. return false;
  49. }
  50.  
  51. }
Add Comment
Please, Sign In to add comment