public void permaBanOffline(
     String punisher, String punisherDisplay, String punished, ArrayList<String> arguments) {
   try {
     String reason = "";
     for (String s : arguments) {
       reason += s + " ";
     }
     long time = System.currentTimeMillis() / 1000L;
     UUID UUID = plugin.getServer().getOfflinePlayer(punished).getUniqueId();
     plugin.sqlite.insert(
         "INSERT INTO punishments (punisher, punished, reason, type, time, expiry, active, server, UUID) VALUES ('"
             + punisher
             + "','"
             + punished
             + "','"
             + StringEscapeUtils.escapeSql(reason)
             + "','ban','"
             + time
             + "','0','1','"
             + Bans.server
             + "','"
             + UUID
             + "');");
     for (Player plr : plugin.getServer().getOnlinePlayers()) {
       plr.sendMessage(
           ChatColor.DARK_AQUA
               + punisherDisplay
               + ChatColor.YELLOW
               + " -> "
               + ChatColor.GOLD
               + "Permanent ban"
               + ChatColor.YELLOW
               + " -> "
               + ChatColor.DARK_AQUA
               + punished
               + ChatColor.YELLOW
               + " -> "
               + ChatColor.GOLD
               + reason);
     }
     plugin.addBan(UUID, reason, time, 0);
   } catch (SQLException e) {
     plugin.getLogger().severe(e.getMessage());
   }
 }
Example #2
0
  public void punishOffline(
      String punisher, String punisherDisplay, String punished, ArrayList<String> arguments) {
    String reason = "";
    for (String s : arguments) {
      reason += s + " ";
    }
    try {
      ResultSet result =
          plugin.sqlite.query(
              ("SELECT * FROM punishments WHERE punished='" + punished + "' AND active=1;"));
      Boolean kicked = false;
      Boolean banned = false;
      while (result.next()) {
        String type = result.getString("type");
        if (type.equals("ban") || type.equals("tempban")) {
          banned = true;
        } else if (type.equals("kick")) {
          kicked = true;
        }
      }
      long time = System.currentTimeMillis() / 1000L;
      long expiry = time + (86400 * 7);
      UUID UUID = plugin.getServer().getOfflinePlayer(punished).getUniqueId();
      if (banned) {

        plugin.sqlite.insert(
            "INSERT INTO punishments (punisher, punished, reason, type, time, expiry, active, server, UUID) VALUES ('"
                + punisher
                + "','"
                + punished
                + "','"
                + StringEscapeUtils.escapeSql(reason)
                + "','ban','"
                + time
                + "','0','1','"
                + Bans.server
                + "','"
                + UUID
                + "');");
        for (Player plr : plugin.getServer().getOnlinePlayers()) {
          plr.sendMessage(
              ChatColor.DARK_AQUA
                  + punisherDisplay
                  + ChatColor.YELLOW
                  + " -> "
                  + ChatColor.GOLD
                  + "Permanent ban"
                  + ChatColor.YELLOW
                  + " -> "
                  + ChatColor.DARK_AQUA
                  + punished
                  + ChatColor.YELLOW
                  + " -> "
                  + ChatColor.GOLD
                  + reason);
        }
        plugin.addBan(UUID, reason, time, 0);
      } else if (kicked) {
        plugin.sqlite.insert(
            "INSERT INTO punishments (punisher, punished, reason, type, time, expiry, active, server, UUID) VALUES ('"
                + punisher
                + "','"
                + punished
                + "','"
                + StringEscapeUtils.escapeSql(reason)
                + "','tempban','"
                + time
                + "','"
                + expiry
                + "','1','"
                + Bans.server
                + "','"
                + UUID
                + "');");
        for (Player plr : plugin.getServer().getOnlinePlayers()) {
          plr.sendMessage(
              ChatColor.DARK_AQUA
                  + punisherDisplay
                  + ChatColor.YELLOW
                  + " -> "
                  + ChatColor.GOLD
                  + "7 day ban"
                  + ChatColor.YELLOW
                  + " -> "
                  + ChatColor.DARK_AQUA
                  + punished
                  + ChatColor.YELLOW
                  + " -> "
                  + ChatColor.GOLD
                  + reason);
        }
        plugin.addBan(UUID, reason, time, expiry);
      } else {
        plugin.sqlite.insert(
            "INSERT INTO punishments (punisher, punished, reason, type, time, active, server, UUID) VALUES ('"
                + punisher
                + "','"
                + punished
                + "','"
                + StringEscapeUtils.escapeSql(reason)
                + "','kick','"
                + time
                + "','1','"
                + Bans.server
                + "','"
                + UUID
                + "');");
        for (Player plr : plugin.getServer().getOnlinePlayers()) {
          plr.sendMessage(
              punisherDisplay
                  + ChatColor.YELLOW
                  + " -> "
                  + ChatColor.GOLD
                  + "Kick"
                  + ChatColor.YELLOW
                  + " -> "
                  + ChatColor.DARK_AQUA
                  + punished
                  + ChatColor.YELLOW
                  + " -> "
                  + ChatColor.GOLD
                  + reason);
        }
      }
    } catch (SQLException e) {
      plugin.getLogger().severe(e.getMessage());
    }
  }