Advertisement
imBEheAR

Untitled

May 5th, 2021
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. public class HelpOp implements CommandExecutor {
  2.  
  3.     Main plugin;
  4.  
  5.     HashMap<Player, Long> spamhelpop = new HashMap<Player, Long>();
  6.    
  7.     public HelpOp(Main m) {
  8.         plugin = m;
  9.         m.getCommand("helpop").setExecutor(this);
  10.     }
  11.    
  12.     @Override
  13.     public boolean onCommand(CommandSender sender, Command arg1, String arg2, String[] args) {
  14.         if(sender instanceof Player) {
  15.             if(args.length >= 1) {
  16.                 Player p = (Player) sender;
  17.                
  18.                 if(spamhelpop.containsKey(p)) {
  19.                     if(spamhelpop.get(p) > System.currentTimeMillis()) {
  20.                         Util.sendMessage(p, " &d&lHELPOP&8 :: &fMusisz poczekac przez uzyciem tej komendy!");
  21.                     } else {
  22.                         StringBuilder sb = new StringBuilder();
  23.                        
  24.                         for(int i = 0; i < args.length; ++i) {
  25.                             sb.append(args[i]).append(" ");
  26.                         }
  27.                        
  28.                         String msg = sb.toString();
  29.                        
  30.                         for(Player ps : Bukkit.getOnlinePlayers()) {
  31.                             if(ps.hasPermission("galaxyhc.helpop")) {
  32.                                 Util.sendMessage(ps, " &d&lHELPOP&8 :: &f" + p.getDisplayName() + "&8: &d" + msg);
  33.                             }
  34.                         }
  35.                        
  36.                         spamhelpop.put(p, System.currentTimeMillis() + 30 * 1000);
  37.                     }
  38.                 } else {
  39.                     StringBuilder sb = new StringBuilder();
  40.                    
  41.                     for(int i = 0; i < args.length; ++i) {
  42.                         sb.append(args[i]).append(" ");
  43.                     }
  44.                    
  45.                     String msg = sb.toString();
  46.                    
  47.                     for(Player ps : Bukkit.getOnlinePlayers()) {
  48.                         if(ps.hasPermission("galaxyhc.helpop")) {
  49.                             Util.sendMessage(ps, " &d&lHELPOP&8 :: &f" + p.getDisplayName() + "&8: &d" + msg);
  50.                         }
  51.                     }
  52.                    
  53.                     spamhelpop.put(p, System.currentTimeMillis() + 30 * 1000);
  54.                 }
  55.             }
  56.         }
  57.  
  58.        
  59.         return false;
  60.     }
  61.    
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement