|
|
@ -12,7 +12,6 @@ package engine.db.handlers; |
|
|
|
import engine.Enum; |
|
|
|
import engine.Enum; |
|
|
|
import engine.Enum.GameObjectType; |
|
|
|
import engine.Enum.GameObjectType; |
|
|
|
import engine.gameManager.DbManager; |
|
|
|
import engine.gameManager.DbManager; |
|
|
|
import engine.objects.AbstractGameObject; |
|
|
|
|
|
|
|
import engine.objects.MaxSkills; |
|
|
|
import engine.objects.MaxSkills; |
|
|
|
import engine.objects.SkillsBase; |
|
|
|
import engine.objects.SkillsBase; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
@ -34,63 +33,83 @@ public class dbSkillBaseHandler extends dbHandlerBase { |
|
|
|
public SkillsBase GET_BASE(final int objectUUID) { |
|
|
|
public SkillsBase GET_BASE(final int objectUUID) { |
|
|
|
|
|
|
|
|
|
|
|
SkillsBase skillsBase = (SkillsBase) DbManager.getFromCache(GameObjectType.SkillsBase, objectUUID); |
|
|
|
SkillsBase skillsBase = (SkillsBase) DbManager.getFromCache(GameObjectType.SkillsBase, objectUUID); |
|
|
|
|
|
|
|
|
|
|
|
if (skillsBase != null) |
|
|
|
if (skillsBase != null) |
|
|
|
return skillsBase; |
|
|
|
return skillsBase; |
|
|
|
prepareCallable("SELECT * FROM static_skill_skillsbase WHERE ID = ?"); |
|
|
|
|
|
|
|
setInt(1, objectUUID); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
SkillsBase sb; |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_skill_skillsbase WHERE ID = ?")) { |
|
|
|
sb = (SkillsBase) getObjectSingle(objectUUID); |
|
|
|
|
|
|
|
SkillsBase.putInCache(sb); |
|
|
|
preparedStatement.setInt(1, objectUUID); |
|
|
|
return sb; |
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
skillsBase = (SkillsBase) getObjectFromRs(rs); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SkillsBase.putInCache(skillsBase); |
|
|
|
|
|
|
|
return skillsBase; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public SkillsBase GET_BASE_BY_NAME(String name) { |
|
|
|
public SkillsBase GET_BASE_BY_NAME(String name) { |
|
|
|
SkillsBase sb = SkillsBase.getFromCache(name); |
|
|
|
|
|
|
|
if (sb != null) { |
|
|
|
SkillsBase skillsBase = SkillsBase.getFromCache(name); |
|
|
|
return sb; |
|
|
|
|
|
|
|
} |
|
|
|
if (skillsBase != null) |
|
|
|
prepareCallable("SELECT * FROM static_skill_skillsbase WHERE name = ?"); |
|
|
|
return skillsBase; |
|
|
|
setString(1, name); |
|
|
|
|
|
|
|
ArrayList<AbstractGameObject> result = getObjectList(); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
if (result.size() > 0) { |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_skill_skillsbase WHERE name = ?")) { |
|
|
|
sb = (SkillsBase) result.get(0); |
|
|
|
|
|
|
|
SkillsBase.putInCache(sb); |
|
|
|
preparedStatement.setString(1, name); |
|
|
|
return sb; |
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
} else { |
|
|
|
|
|
|
|
return null; |
|
|
|
skillsBase = (SkillsBase) getObjectFromRs(rs); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SkillsBase.putInCache(skillsBase); |
|
|
|
|
|
|
|
return skillsBase; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public SkillsBase GET_BASE_BY_TOKEN(final int token) { |
|
|
|
public SkillsBase GET_BASE_BY_TOKEN(final int token) { |
|
|
|
SkillsBase sb = SkillsBase.getFromCache(token); |
|
|
|
|
|
|
|
if (sb != null) { |
|
|
|
|
|
|
|
return sb; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("SELECT * FROM static_skill_skillsbase WHERE token = ?"); |
|
|
|
SkillsBase skillsBase = SkillsBase.getFromCache(token); |
|
|
|
setInt(1, token); |
|
|
|
|
|
|
|
ArrayList<AbstractGameObject> result = getObjectList(); |
|
|
|
if (skillsBase != null) |
|
|
|
if (result.size() > 0) { |
|
|
|
return skillsBase; |
|
|
|
sb = (SkillsBase) result.get(0); |
|
|
|
|
|
|
|
SkillsBase.putInCache(sb); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
return sb; |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_skill_skillsbase WHERE token = ?")) { |
|
|
|
} else { |
|
|
|
|
|
|
|
return null; |
|
|
|
preparedStatement.setInt(1, token); |
|
|
|
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
skillsBase = (SkillsBase) getObjectFromRs(rs); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SkillsBase.putInCache(skillsBase); |
|
|
|
|
|
|
|
return skillsBase; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void LOAD_ALL_MAX_SKILLS_FOR_CONTRACT() { |
|
|
|
public void LOAD_ALL_MAX_SKILLS_FOR_CONTRACT() { |
|
|
|
|
|
|
|
|
|
|
|
prepareCallable("SELECT * FROM `static_rune_maxskills`"); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_maxskills`")) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
ResultSet rs = executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//shrines cached in rs for easy cache on creation.
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
while (rs.next()) { |
|
|
|
|
|
|
|
|
|
|
|
MaxSkills maxSKills = new MaxSkills(rs); |
|
|
|
MaxSkills maxSKills = new MaxSkills(rs); |
|
|
|
|
|
|
|
|
|
|
|
if (MaxSkills.MaxSkillsSet.get(maxSKills.getRuneID()) == null) { |
|
|
|
if (MaxSkills.MaxSkillsSet.get(maxSKills.getRuneID()) == null) { |
|
|
|
ArrayList<MaxSkills> newMaxSkillsList = new ArrayList<>(); |
|
|
|
ArrayList<MaxSkills> newMaxSkillsList = new ArrayList<>(); |
|
|
|
newMaxSkillsList.add(maxSKills); |
|
|
|
newMaxSkillsList.add(maxSKills); |
|
|
@ -100,17 +119,13 @@ public class dbSkillBaseHandler extends dbHandlerBase { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
Logger.error(e.getErrorCode() + ' ' + e.getMessage(), e); |
|
|
|
Logger.error(e); |
|
|
|
} finally { |
|
|
|
|
|
|
|
closeCallable(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void LOAD_ALL_RUNE_SKILLS() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void LOAD_ALL_RUNE_SKILLS() { |
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_skill_skillsgranted`")) { |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_skill_skillsgranted`")) { |
|
|
|