コード例 #1
0
  public void insertRecord(final BanRecord record) {
    Validate.notNull(record, "The record cannot be null!");
    if (record.getDuration() < 0
        || record.getDuration()
            > 10000) { // Only insert the database if the ban is permanent or lasts longer than 10
                       // seconds!
      CraftoMessenger.debug("Inserting ban record to database...");
      final String query =
          "INSERT INTO `cp_bans` (`player_id`, `banned_by`, `reason`, `duration`, `created_at`) VALUES ("
              + record.getPlayer().getId()
              + ", "
              + record.getBannedBy().getId()
              + ", "
              + (record.getReason().isPresent() ? "'" + record.getReason().get() + "'" : "NULL")
              + ", "
              + record.getDuration()
              + ", '"
              + record.getCreationTime().toString()
              + "') ON DUPLICATE KEY UPDATE id=id;";
      this.module.getPlugin().getScheduler().registerNewQuery(query);
    } else {
      CraftoMessenger.debug("Skipping inserting ban record to database.");
    }

    // But always insert into ram
    this.map.put(record.getPlayer().getUniqueId(), record);
  }
コード例 #2
0
 public void clear() {
   this.map.clear();
   CraftoMessenger.debug("Cleared bandatabase ram!");
 }