public static PlayerQuestModel loadById(int id) { String query = "select * from quest_player_quests where id = ?"; HashMap<Integer, Object> params = new HashMap<Integer, Object>(); params.put(1, id); ResultSet rs = Quests.db.select(query, params); try { if (rs != null && rs.next()) { PlayerQuestModel obj = new PlayerQuestModel(); obj.populate(rs); return obj; } } catch (SQLException e) { e.printStackTrace(); } return null; }
public static PlayerQuestModel create(PlayerModel player, QuestModel quest) { String query = "insert into quest_player_quests (player_id, quest_id, series_id, status, progress, created, cycle, reward, streak_bonus, cycle_bonus, processed) "; query += "values (?, ?, ?, 0, 0, now(), ?, 0, 0, 0, 0)"; HashMap<Integer, Object> params = new HashMap<Integer, Object>(); params.put(1, player.Id); params.put(2, quest.Id); params.put(3, PluginConfig.SERIES_ID); params.put(4, player.Cycle); int id = Quests.db.insert(query, params); if (id > 0) { return PlayerQuestModel.loadById(id); } return null; }