forked from MagicBane/Server
Refactor to remove abstraction
This commit is contained in:
@@ -9,8 +9,14 @@
|
||||
|
||||
package engine.db.handlers;
|
||||
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.MenuOption;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class dbMenuHandler extends dbHandlerBase {
|
||||
@@ -21,8 +27,21 @@ public class dbMenuHandler extends dbHandlerBase {
|
||||
}
|
||||
|
||||
public ArrayList<MenuOption> GET_MENU_OPTIONS(final int id) {
|
||||
prepareCallable("SELECT * FROM `static_npc_menuoption` WHERE menuID = ?");
|
||||
setInt(1, id);
|
||||
return getObjectList();
|
||||
|
||||
ArrayList<MenuOption> menuOptions = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_menuoption` WHERE menuID = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, id);
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
menuOptions = getObjectsFromRs(rs, 1000);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
return menuOptions;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user