Exemplo n.º 1
0
  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");
  }
Exemplo n.º 2
0
 public boolean isBanned(Player p) {
   int i = settings.getConfig().getInt("Banned." + p.getUniqueId() + ".isbanned");
   if (i == 0) {
     return false;
   } else {
     return true;
   }
 }
Exemplo n.º 3
0
 public int getTime(Player p) {
   return settings.getConfig().getInt("Banned." + p.getUniqueId() + ".time");
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 public String getReason(Player p) {
   return settings.getConfig().getString("Banned." + p.getUniqueId() + ".reason");
 }
Exemplo n.º 6
0
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");
  }
}