h31ix

Untitled

Jan 11th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. //Make a ban that uses the name CONSOLE instead of the player
  2. public void createConsoleBan(String player, String admin, String reason, int time)
  3. {
  4. Calendar cal = Calendar.getInstance();
  5. int year = cal.get(Calendar.YEAR);
  6. int month = cal.get(Calendar.MONTH);
  7. int day = cal.get(Calendar.DATE);
  8. Date date = new Date(year - 1900, month, day);
  9. SimpleDateFormat dformat = new SimpleDateFormat("MM/dd/yy");
  10. String formattedDate = dformat.format(date);
  11. long ends = 0;
  12. if (time != 0)
  13. {
  14. long unixTime = System.currentTimeMillis() / 1000L;
  15. ends = unixTime = (time*60);
  16. }
  17. try {
  18. PreparedStatement sampleQueryStatement = NASConnection.prepareStatement("INSERT INTO "+config.getString("MySQLSettings.Bans Table")+" (sid, date, type, player_steamid, player_ip, player_mcname, player_name, admin_steamid, admin_ip, admin_mcname, admin_name, unbanned_by, length, ends, reason, status) VALUES ('4', '"+formattedDate+"', 'MC', 'NULL', 'NULL', '"+player+"', 'NULL', 'NULL', 'NULL', '"+admin+"', 'NULL', 'NULL', '"+time+"', '"+ends+"', '"+reason+"', '1')");
  19. sampleQueryStatement.executeUpdate();
  20. sampleQueryStatement.close();
  21. getServer().broadcastMessage("[NAS] Admin: "+ChatColor.GREEN+admin+ChatColor.WHITE+" banned "+ChatColor.GREEN+player+ChatColor.WHITE+" for "+ChatColor.GREEN+reason);
  22. } catch (SQLException ex) {
  23. Logger.getLogger(Nas.class.getName()).log(Level.SEVERE, null, ex);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment