public void ban(Player p, ArrayList<String> reason) { String s = reason + ""; settings.getConfig().set("Banned." + p.getUniqueId() + ".reason", s); settings.getConfig().set("Banned." + p.getUniqueId() + ".isbanned", 1); settings.getConfig().set("Banned." + p.getUniqueId() + ".time", -10); players.add(p); settings.saveConfig(); p.kickPlayer("Banned"); }
public boolean isBanned(Player p) { int i = settings.getConfig().getInt("Banned." + p.getUniqueId() + ".isbanned"); if (i == 0) { return false; } else { return true; } }
public int getTime(Player p) { return settings.getConfig().getInt("Banned." + p.getUniqueId() + ".time"); }
public void unBan(Player p) { if (!isBanned(p)) return; settings.getConfig().set("Banned." + p.getUniqueId() + ".isbanned", 0); players.remove(p); settings.getConfig().set("Banned." + p.getUniqueId() + ".time", 0); }
public String getReason(Player p) { return settings.getConfig().getString("Banned." + p.getUniqueId() + ".reason"); }
public class BanManager { ArrayList<Player> players = new ArrayList<>(); private static BanManager instance = new BanManager(); int id; SettingsManager settings = SettingsManager.getInstance(); private BanManager() {} public void timer() { id = Bukkit.getServer() .getScheduler() .scheduleSyncRepeatingTask( Main.getPlugin(), new Runnable() { public void run() { try { for (Player p : players) { int i = settings.getConfig().getInt("Banned." + p.getUniqueId() + ".time"); if (i == 0) { settings.getConfig().set("Banned." + p.getUniqueId() + ".isbanned", 0); players.remove(p); settings.getConfig().set("Banned." + p.getUniqueId() + ".time", i); } else if (i == -10) { } else { i--; settings.getConfig().set("Banned." + p.getUniqueId() + ".time", i); } settings.saveConfig(); } } catch (Exception e) { } } }, 0, 20L); } public static BanManager getInstance() { return instance; } public void unBan(Player p) { if (!isBanned(p)) return; settings.getConfig().set("Banned." + p.getUniqueId() + ".isbanned", 0); players.remove(p); settings.getConfig().set("Banned." + p.getUniqueId() + ".time", 0); } public void ban(Player p, ArrayList<String> reason, int time) { String s = reason + ""; s.replaceAll(",", ""); settings.getConfig().set("Banned." + p.getUniqueId() + ".reason", s); settings.getConfig().set("Banned." + p.getUniqueId() + ".isbanned", 1); settings.getConfig().set("Banned." + p.getUniqueId() + ".time", time); players.add(p); settings.saveConfig(); p.kickPlayer("Banned"); } public void ban(Player p, ArrayList<String> reason) { String s = reason + ""; settings.getConfig().set("Banned." + p.getUniqueId() + ".reason", s); settings.getConfig().set("Banned." + p.getUniqueId() + ".isbanned", 1); settings.getConfig().set("Banned." + p.getUniqueId() + ".time", -10); players.add(p); settings.saveConfig(); p.kickPlayer("Banned"); } public int getTime(Player p) { return settings.getConfig().getInt("Banned." + p.getUniqueId() + ".time"); } public boolean isBanned(Player p) { int i = settings.getConfig().getInt("Banned." + p.getUniqueId() + ".isbanned"); if (i == 0) { return false; } else { return true; } } public String getReason(Player p) { return settings.getConfig().getString("Banned." + p.getUniqueId() + ".reason"); } }