AlanGomes

Untitled

Feb 13th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. // Mude por um arquivo onde ira ficar os bans
  2. public FileConfiguration cfg=getConfig();
  3.  
  4.  
  5. // Salvar arquivo
  6. public static void saveCfg() {
  7. saveConfig();
  8. }
  9.  
  10. // tempo em segundos
  11. public static void banir(Player p, int tempo, String motivo) {
  12. long timestamp = System.currentTimeMillis() / 1000;
  13. cfg.set("Bans."+p.getName()+".TempoAtual", timestamp);
  14. cfg.set("Bans."+p.getName()+".Tempo", tempo);
  15. cfg.set("Bans."+p.getName()+".Motivo", motivo);
  16. saveCfg();
  17. p.kickPlayer(motivo);
  18. }
  19.  
  20. public static boolean estaBanido(Player p) {
  21. for (String key:cfg.getConfigurationSection("Bans").getKeys(false)) {
  22. if (key.equalsIgnoreCase(p.getName())) {
  23. long timestamp = System.currentTimeMillis() / 1000;
  24. if ((timestamp-cfg.getLong("Bans."+key+".TempoAtual"))>cfg.getInt("Bans."+key+".Tempo")) {
  25. cfg.set("Bans."+key, null);
  26. saveCfg();
  27. return false;
  28. } else {
  29. return true;
  30. }
  31. }
  32. }
  33. return false;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment