|
|
@ -9,9 +9,12 @@ |
|
|
|
|
|
|
|
|
|
|
|
package engine.db.handlers; |
|
|
|
package engine.db.handlers; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import engine.gameManager.DbManager; |
|
|
|
import engine.objects.PromotionClass; |
|
|
|
import engine.objects.PromotionClass; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.Connection; |
|
|
|
|
|
|
|
import java.sql.PreparedStatement; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
@ -24,31 +27,59 @@ public class dbPromotionClassHandler extends dbHandlerBase { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ArrayList<Integer> GET_ALLOWED_RUNES(final PromotionClass pc) { |
|
|
|
public ArrayList<Integer> GET_ALLOWED_RUNES(final PromotionClass pc) { |
|
|
|
ArrayList<Integer> runes = new ArrayList<>(); |
|
|
|
|
|
|
|
prepareCallable("SELECT * FROM `static_rune_promotionrunereq` WHERE `promoID`=?"); |
|
|
|
ArrayList<Integer> runeList = new ArrayList<>(); |
|
|
|
setInt(1, pc.getObjectUUID()); |
|
|
|
|
|
|
|
try { |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_promotionrunereq` WHERE `promoID`=?")) { |
|
|
|
while (rs.next()) { |
|
|
|
|
|
|
|
runes.add(rs.getInt("runereqID")); |
|
|
|
preparedStatement.setInt(1, pc.getObjectUUID()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) |
|
|
|
|
|
|
|
runeList.add(rs.getInt("runereqID")); |
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error("Failed to retrieve Allowed Runes for PromotionClass " + pc.getObjectUUID() + ". Error number: " + e.getErrorCode(), e); |
|
|
|
Logger.error(e); |
|
|
|
return null; |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return runes; |
|
|
|
return runeList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public PromotionClass GET_PROMOTION_CLASS(final int objectUUID) { |
|
|
|
public PromotionClass GET_PROMOTION_CLASS(final int objectUUID) { |
|
|
|
prepareCallable("SELECT * FROM `static_rune_promotion` WHERE `ID` = ?"); |
|
|
|
|
|
|
|
setInt(1, objectUUID); |
|
|
|
PromotionClass promotionClass = null; |
|
|
|
return (PromotionClass) getObjectSingle(objectUUID); |
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_promotion` WHERE `ID` = ?")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preparedStatement.setInt(1, objectUUID); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
promotionClass = (PromotionClass) getObjectFromRs(rs); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return promotionClass; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ArrayList<PromotionClass> GET_ALL_PROMOTIONS() { |
|
|
|
public ArrayList<PromotionClass> GET_ALL_PROMOTIONS() { |
|
|
|
prepareCallable("SELECT * FROM `static_rune_promotion`"); |
|
|
|
|
|
|
|
return getObjectList(); |
|
|
|
ArrayList<PromotionClass> promotionList = new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_promotion`")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
promotionList = getObjectsFromRs(rs, 30); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return promotionList; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|