Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List[] getRanking(int stat) {
- List[] rank = new List[3];
- Connection connection = getNewConnection();
- if(connection != null) {
- Statement state = null;
- try {
- state = connection.createStatement();
- String st = "game";
- switch(stat) {
- case 1:
- st = "kill";
- break;
- case 2:
- st = "death";
- break;
- case 3:
- st = "win";
- break;
- case 4:
- st = "feast";
- break;
- case 5:
- st = "spec";
- break;
- case 6:
- st = "rand";
- break;
- default:
- st = "game";
- }
- ResultSet s = state.executeQuery("SELECT `uuid`,`username`,`rank_" + st + "` FROM `nhg`.`st_user` ORDER BY `rank_" + st + "` DESC LIMIT 25");
- if(s != null) {
- List<String> uuid = new ArrayList<>();
- List<String> players = new ArrayList<>();
- List<Integer> stats = new ArrayList<>();
- while(s.next()) {
- uuid.add(s.getString("uuid"));
- players.add(s.getString("username"));
- stats.add(s.getInt("rank_" + st));
- }
- s.close();
- rank = new List[] {uuid, players, stats};
- }
- }
- catch(SQLException e) {
- e.printStackTrace();
- SQLLog.logAndMail("", e.toString(), e.getStackTrace());
- }
- finally {
- safeClose(connection, state);
- }
- }
- return rank;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement