Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Mude por um arquivo onde ira ficar os bans
- public FileConfiguration cfg=getConfig();
- // Salvar arquivo
- public static void saveCfg() {
- saveConfig();
- }
- // tempo em segundos
- public static void banir(Player p, int tempo, String motivo) {
- long timestamp = System.currentTimeMillis() / 1000;
- cfg.set("Bans."+p.getName()+".TempoAtual", timestamp);
- cfg.set("Bans."+p.getName()+".Tempo", tempo);
- cfg.set("Bans."+p.getName()+".Motivo", motivo);
- saveCfg();
- p.kickPlayer(motivo);
- }
- public static boolean estaBanido(Player p) {
- for (String key:cfg.getConfigurationSection("Bans").getKeys(false)) {
- if (key.equalsIgnoreCase(p.getName())) {
- long timestamp = System.currentTimeMillis() / 1000;
- if ((timestamp-cfg.getLong("Bans."+key+".TempoAtual"))>cfg.getInt("Bans."+key+".Tempo")) {
- cfg.set("Bans."+key, null);
- saveCfg();
- return false;
- } else {
- return true;
- }
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment