Project cleanup pre merge.

This commit is contained in:
2023-07-15 09:23:48 -04:00
parent 134b651df8
commit 9bbdef224d
747 changed files with 99704 additions and 101200 deletions
+18 -18
View File
@@ -21,31 +21,31 @@ import java.util.ArrayList;
public class dbBoonHandler extends dbHandlerBase {
public dbBoonHandler() {
}
public dbBoonHandler() {
}
public ArrayList<Boon> GET_BOON_AMOUNTS_FOR_ITEMBASE(int itemBaseUUID) {
public ArrayList<Boon> GET_BOON_AMOUNTS_FOR_ITEMBASE(int itemBaseUUID) {
ArrayList<Boon> boons = new ArrayList<>();
Boon thisBoon;
ArrayList<Boon> boons = new ArrayList<>();
Boon thisBoon;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_boons` WHERE `itemBaseID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_boons` WHERE `itemBaseID` = ?")) {
preparedStatement.setInt(1, itemBaseUUID);
preparedStatement.setInt(1, itemBaseUUID);
ResultSet rs = preparedStatement.executeQuery();
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
thisBoon = new Boon(rs);
boons.add(thisBoon);
}
while (rs.next()) {
thisBoon = new Boon(rs);
boons.add(thisBoon);
}
} catch (SQLException e) {
Logger.error(e);
}
} catch (SQLException e) {
Logger.error(e);
}
return boons;
}
return boons;
}
}
+62 -62
View File
@@ -24,91 +24,91 @@ import java.sql.SQLException;
public class dbCSSessionHandler extends dbHandlerBase {
public dbCSSessionHandler() {
this.localClass = CSSession.class;
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public dbCSSessionHandler() {
this.localClass = CSSession.class;
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public boolean ADD_CSSESSION(String secKey, Account acc, InetAddress inet, String machineID) {
public boolean ADD_CSSESSION(String secKey, Account acc, InetAddress inet, String machineID) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_session` (`secretKey`, `accountID`, `discordAccount`, `sessionIP`, machineID) VALUES (?,?,?,INET_ATON(?),?)")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_session` (`secretKey`, `accountID`, `discordAccount`, `sessionIP`, machineID) VALUES (?,?,?,INET_ATON(?),?)")) {
preparedStatement.setString(1, secKey);
preparedStatement.setLong(2, acc.getObjectUUID());
preparedStatement.setString(3, acc.discordAccount);
preparedStatement.setString(4, StringUtils.InetAddressToClientString(inet));
preparedStatement.setString(5, machineID);
preparedStatement.setString(1, secKey);
preparedStatement.setLong(2, acc.getObjectUUID());
preparedStatement.setString(3, acc.discordAccount);
preparedStatement.setString(4, StringUtils.InetAddressToClientString(inet));
preparedStatement.setString(5, machineID);
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean DELETE_UNUSED_CSSESSION(String secKey) {
public boolean DELETE_UNUSED_CSSESSION(String secKey) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_session` WHERE `secretKey`=? && `characterID` IS NULL")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_session` WHERE `secretKey`=? && `characterID` IS NULL")) {
preparedStatement.setString(1, secKey);
return (preparedStatement.executeUpdate() > 0);
preparedStatement.setString(1, secKey);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean DELETE_CSSESSION(String secKey) {
public boolean DELETE_CSSESSION(String secKey) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_session` WHERE `secretKey`=?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_session` WHERE `secretKey`=?")) {
preparedStatement.setString(1, secKey);
return (preparedStatement.executeUpdate() > 0);
preparedStatement.setString(1, secKey);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean UPDATE_CSSESSION(String secKey, int charID) {
public boolean UPDATE_CSSESSION(String secKey, int charID) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_session` SET `characterID`=? WHERE `secretKey`=?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_session` SET `characterID`=? WHERE `secretKey`=?")) {
preparedStatement.setInt(1, charID);
preparedStatement.setString(2, secKey);
preparedStatement.setInt(1, charID);
preparedStatement.setString(2, secKey);
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public CSSession GET_CSSESSION(String secKey) {
public CSSession GET_CSSESSION(String secKey) {
CSSession css = null;
CSSession css = null;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `accountID`, `characterID`, `machineID` FROM `dyn_session` WHERE `secretKey`=?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `accountID`, `characterID`, `machineID` FROM `dyn_session` WHERE `secretKey`=?")) {
preparedStatement.setString(1, secKey);
ResultSet rs = preparedStatement.executeQuery();
preparedStatement.setString(1, secKey);
ResultSet rs = preparedStatement.executeQuery();
if (rs.next())
css = new CSSession(secKey, DbManager.AccountQueries.GET_ACCOUNT(rs.getInt("accountID")), PlayerCharacter.getPlayerCharacter(rs.getInt("characterID")), rs.getString("machineID"));
if (rs.next())
css = new CSSession(secKey, DbManager.AccountQueries.GET_ACCOUNT(rs.getInt("accountID")), PlayerCharacter.getPlayerCharacter(rs.getInt("characterID")), rs.getString("machineID"));
} catch (SQLException e) {
Logger.error(e);
}
} catch (SQLException e) {
Logger.error(e);
}
return css;
}
return css;
}
}
@@ -22,152 +22,152 @@ import java.util.concurrent.ConcurrentHashMap;
public class dbCharacterSkillHandler extends dbHandlerBase {
public dbCharacterSkillHandler() {
this.localClass = CharacterSkill.class;
this.localObjectType = Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public dbCharacterSkillHandler() {
this.localClass = CharacterSkill.class;
this.localObjectType = Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public CharacterSkill ADD_SKILL(CharacterSkill toAdd) {
public CharacterSkill ADD_SKILL(CharacterSkill toAdd) {
CharacterSkill characterSkill = null;
CharacterSkill characterSkill = null;
if (CharacterSkill.GetOwner(toAdd) == null || toAdd.getSkillsBase() == null) {
Logger.error("dbCharacterSkillHandler.ADD_SKILL", toAdd.getObjectUUID() + " missing owner or skillsBase");
return null;
}
if (CharacterSkill.GetOwner(toAdd) == null || toAdd.getSkillsBase() == null) {
Logger.error("dbCharacterSkillHandler.ADD_SKILL", toAdd.getObjectUUID() + " missing owner or skillsBase");
return null;
}
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_character_skill` (`CharacterID`, `skillsBaseID`, `trains`) VALUES (?, ?, ?);", Statement.RETURN_GENERATED_KEYS)) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_character_skill` (`CharacterID`, `skillsBaseID`, `trains`) VALUES (?, ?, ?);", Statement.RETURN_GENERATED_KEYS)) {
preparedStatement.setLong(1, CharacterSkill.GetOwner(toAdd).getObjectUUID());
preparedStatement.setInt(2, toAdd.getSkillsBase().getObjectUUID());
preparedStatement.setInt(3, toAdd.getNumTrains());
preparedStatement.setLong(1, CharacterSkill.GetOwner(toAdd).getObjectUUID());
preparedStatement.setInt(2, toAdd.getSkillsBase().getObjectUUID());
preparedStatement.setInt(3, toAdd.getNumTrains());
preparedStatement.executeUpdate();
ResultSet rs = preparedStatement.getGeneratedKeys();
preparedStatement.executeUpdate();
ResultSet rs = preparedStatement.getGeneratedKeys();
if (rs.next())
characterSkill = GET_SKILL(rs.getInt(1));
if (rs.next())
characterSkill = GET_SKILL(rs.getInt(1));
} catch (SQLException e) {
Logger.error(e);
}
return characterSkill;
}
} catch (SQLException e) {
Logger.error(e);
}
return characterSkill;
}
public boolean DELETE_SKILL(final int objectUUID) {
public boolean DELETE_SKILL(final int objectUUID) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_character_skill` WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_character_skill` WHERE `UID` = ?")) {
preparedStatement.setLong(1, objectUUID);
preparedStatement.setLong(1, objectUUID);
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public CharacterSkill GET_SKILL(final int objectUUID) {
public CharacterSkill GET_SKILL(final int objectUUID) {
CharacterSkill characterSkill = (CharacterSkill) DbManager.getFromCache(Enum.GameObjectType.CharacterSkill, objectUUID);
CharacterSkill characterSkill = (CharacterSkill) DbManager.getFromCache(Enum.GameObjectType.CharacterSkill, objectUUID);
if (characterSkill != null)
return characterSkill;
if (characterSkill != null)
return characterSkill;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_character_skill` WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_character_skill` WHERE `UID` = ?")) {
preparedStatement.setInt(1, objectUUID);
ResultSet rs = preparedStatement.executeQuery();
preparedStatement.setInt(1, objectUUID);
ResultSet rs = preparedStatement.executeQuery();
characterSkill = (CharacterSkill) getObjectFromRs(rs);
characterSkill = (CharacterSkill) getObjectFromRs(rs);
} catch (SQLException e) {
Logger.error(e);
}
return characterSkill;
}
} catch (SQLException e) {
Logger.error(e);
}
return characterSkill;
}
public ConcurrentHashMap<String, CharacterSkill> GET_SKILLS_FOR_CHARACTER(final AbstractCharacter ac) {
public ConcurrentHashMap<String, CharacterSkill> GET_SKILLS_FOR_CHARACTER(final AbstractCharacter ac) {
ConcurrentHashMap<String, CharacterSkill> characterSkills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
ConcurrentHashMap<String, CharacterSkill> characterSkills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
if (ac == null || (!(ac.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))))
return characterSkills;
if (ac == null || (!(ac.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))))
return characterSkills;
PlayerCharacter playerCharacter = (PlayerCharacter) ac;
int characterId = playerCharacter.getObjectUUID();
PlayerCharacter playerCharacter = (PlayerCharacter) ac;
int characterId = playerCharacter.getObjectUUID();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_character_skill` WHERE `CharacterID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_character_skill` WHERE `CharacterID` = ?")) {
preparedStatement.setInt(1, characterId);
preparedStatement.setInt(1, characterId);
ResultSet rs = preparedStatement.executeQuery();
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
CharacterSkill cs = new CharacterSkill(rs, playerCharacter);
if (cs.getSkillsBase() != null)
characterSkills.put(cs.getSkillsBase().getName(), cs);
}
while (rs.next()) {
CharacterSkill cs = new CharacterSkill(rs, playerCharacter);
if (cs.getSkillsBase() != null)
characterSkills.put(cs.getSkillsBase().getName(), cs);
}
} catch (SQLException e) {
Logger.error(e);
}
} catch (SQLException e) {
Logger.error(e);
}
return characterSkills;
}
return characterSkills;
}
public void UPDATE_TRAINS(final CharacterSkill characterSkill) {
public void UPDATE_TRAINS(final CharacterSkill characterSkill) {
if (!characterSkill.isTrained())
return;
if (!characterSkill.isTrained())
return;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_character_skill` SET `trains`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_character_skill` SET `trains`=? WHERE `UID` = ?")) {
preparedStatement.setShort(1, (short) characterSkill.getNumTrains());
preparedStatement.setLong(2, characterSkill.getObjectUUID());
preparedStatement.setShort(1, (short) characterSkill.getNumTrains());
preparedStatement.setLong(2, characterSkill.getObjectUUID());
if (preparedStatement.executeUpdate() != 0)
characterSkill.syncTrains();
if (preparedStatement.executeUpdate() != 0)
characterSkill.syncTrains();
} catch (SQLException e) {
Logger.error(e);
}
}
} catch (SQLException e) {
Logger.error(e);
}
}
public void updateDatabase(final CharacterSkill characterSkill) {
public void updateDatabase(final CharacterSkill characterSkill) {
if (characterSkill.getSkillsBase() == null) {
Logger.error("Failed to find skillsBase for Skill " + characterSkill.getObjectUUID());
return;
}
if (characterSkill.getSkillsBase() == null) {
Logger.error("Failed to find skillsBase for Skill " + characterSkill.getObjectUUID());
return;
}
if (CharacterSkill.GetOwner(characterSkill) == null) {
Logger.error("Failed to find owner for Skill " + characterSkill.getObjectUUID());
return;
}
if (CharacterSkill.GetOwner(characterSkill) == null) {
Logger.error("Failed to find owner for Skill " + characterSkill.getObjectUUID());
return;
}
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_character_skill` SET `skillsBaseID`=?, `CharacterID`=?, `trains`=? WHERE `UID`=?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_character_skill` SET `skillsBaseID`=?, `CharacterID`=?, `trains`=? WHERE `UID`=?")) {
preparedStatement.setInt(1, characterSkill.getSkillsBase().getObjectUUID());
preparedStatement.setInt(2, CharacterSkill.GetOwner(characterSkill).getObjectUUID());
preparedStatement.setShort(3, (short) characterSkill.getNumTrains());
preparedStatement.setLong(4, characterSkill.getObjectUUID());
preparedStatement.setInt(1, characterSkill.getSkillsBase().getObjectUUID());
preparedStatement.setInt(2, CharacterSkill.GetOwner(characterSkill).getObjectUUID());
preparedStatement.setShort(3, (short) characterSkill.getNumTrains());
preparedStatement.setLong(4, characterSkill.getObjectUUID());
if (preparedStatement.executeUpdate() != 0)
characterSkill.syncTrains();
if (preparedStatement.executeUpdate() != 0)
characterSkill.syncTrains();
} catch (SQLException e) {
Logger.error(e);
}
} catch (SQLException e) {
Logger.error(e);
}
}
}
}
+104 -104
View File
@@ -23,146 +23,146 @@ import java.sql.SQLException;
public class dbContractHandler extends dbHandlerBase {
public dbContractHandler() {
this.localClass = Contract.class;
this.localObjectType = Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public dbContractHandler() {
this.localClass = Contract.class;
this.localObjectType = Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public Contract GET_CONTRACT(final int objectUUID) {
public Contract GET_CONTRACT(final int objectUUID) {
Contract contract = (Contract) DbManager.getFromCache(Enum.GameObjectType.Contract, objectUUID);
Contract contract = (Contract) DbManager.getFromCache(Enum.GameObjectType.Contract, objectUUID);
if (contract != null)
return contract;
if (contract != null)
return contract;
if (objectUUID == 0)
return null;
if (objectUUID == 0)
return null;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_contract` WHERE `ID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_contract` WHERE `ID` = ?")) {
preparedStatement.setInt(1, objectUUID);
preparedStatement.setInt(1, objectUUID);
ResultSet rs = preparedStatement.executeQuery();
contract = (Contract) getObjectFromRs(rs);
ResultSet rs = preparedStatement.executeQuery();
contract = (Contract) getObjectFromRs(rs);
} catch (SQLException e) {
Logger.error(e);
}
return contract;
}
} catch (SQLException e) {
Logger.error(e);
}
return contract;
}
public void LOAD_CONTRACT_INVENTORY(final Contract contract) {
public void LOAD_CONTRACT_INVENTORY(final Contract contract) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_inventoryset` WHERE `inventorySet` = ?;")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_inventoryset` WHERE `inventorySet` = ?;")) {
preparedStatement.setInt(1, contract.inventorySet);
preparedStatement.setInt(1, contract.inventorySet);
ResultSet rs = preparedStatement.executeQuery();
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
while (rs.next()) {
//handle item base
int itemBaseID = rs.getInt("itembaseID");
//handle item base
int itemBaseID = rs.getInt("itembaseID");
ItemBase ib = ItemBase.getItemBase(itemBaseID);
ItemBase ib = ItemBase.getItemBase(itemBaseID);
if (ib != null) {
if (ib != null) {
MobEquipment me = new MobEquipment(ib, 0, 0);
contract.getSellInventory().add(me);
MobEquipment me = new MobEquipment(ib, 0, 0);
contract.getSellInventory().add(me);
//handle magic effects
String prefix = rs.getString("prefix");
int pRank = rs.getInt("pRank");
String suffix = rs.getString("suffix");
int sRank = rs.getInt("sRank");
//handle magic effects
String prefix = rs.getString("prefix");
int pRank = rs.getInt("pRank");
String suffix = rs.getString("suffix");
int sRank = rs.getInt("sRank");
if (prefix != null) {
me.setPrefix(prefix, pRank);
me.setIsID(true);
}
if (prefix != null) {
me.setPrefix(prefix, pRank);
me.setIsID(true);
}
if (suffix != null) {
me.setSuffix(suffix, sRank);
me.setIsID(true);
}
if (suffix != null) {
me.setSuffix(suffix, sRank);
me.setIsID(true);
}
}
}
} catch (SQLException e) {
Logger.error(e);
}
}
}
}
} catch (SQLException e) {
Logger.error(e);
}
}
public void LOAD_SELL_LIST_FOR_CONTRACT(final Contract contract) {
public void LOAD_SELL_LIST_FOR_CONTRACT(final Contract contract) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_contract_selltype` WHERE `contractID` = ?;")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_npc_contract_selltype` WHERE `contractID` = ?;")) {
preparedStatement.setInt(1, contract.getObjectUUID());
preparedStatement.setInt(1, contract.getObjectUUID());
ResultSet rs = preparedStatement.executeQuery();
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
while (rs.next()) {
int type = rs.getInt("type");
int value = rs.getInt("value");
int type = rs.getInt("type");
int value = rs.getInt("value");
switch (type) {
case 1:
contract.getBuyItemType().add(value);
break;
case 2:
contract.getBuySkillToken().add(value);
break;
case 3:
contract.getBuyUnknownToken().add(value);
break;
}
}
} catch (SQLException e) {
Logger.error(e);
}
}
switch (type) {
case 1:
contract.getBuyItemType().add(value);
break;
case 2:
contract.getBuySkillToken().add(value);
break;
case 3:
contract.getBuyUnknownToken().add(value);
break;
}
}
} catch (SQLException e) {
Logger.error(e);
}
}
public boolean updateAllowedBuildings(final Contract con, final long slotbitvalue) {
public boolean updateAllowedBuildings(final Contract con, final long slotbitvalue) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `static_npc_contract` SET `allowedBuildingTypeID`=? WHERE `contractID`=?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `static_npc_contract` SET `allowedBuildingTypeID`=? WHERE `contractID`=?")) {
preparedStatement.setLong(1, slotbitvalue);
preparedStatement.setInt(2, con.getContractID());
preparedStatement.setLong(1, slotbitvalue);
preparedStatement.setInt(2, con.getContractID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateDatabase(final Contract con) {
public boolean updateDatabase(final Contract con) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `static_npc_contract` SET `contractID`=?, `name`=?, "
+ "`mobbaseID`=?, `classID`=?, vendorDialog=?, iconID=?, allowedBuildingTypeID=? WHERE `ID`=?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `static_npc_contract` SET `contractID`=?, `name`=?, "
+ "`mobbaseID`=?, `classID`=?, vendorDialog=?, iconID=?, allowedBuildingTypeID=? WHERE `ID`=?")) {
preparedStatement.setInt(1, con.getContractID());
preparedStatement.setString(2, con.getName());
preparedStatement.setInt(3, con.getMobbaseID());
preparedStatement.setInt(4, con.getClassID());
preparedStatement.setInt(5, (con.getVendorDialog() != null) ? con.getVendorDialog().getObjectUUID() : 0);
preparedStatement.setInt(6, con.getIconID());
preparedStatement.setInt(8, con.getObjectUUID());
preparedStatement.setLong(7, con.getAllowedBuildings().toLong());
preparedStatement.setInt(1, con.getContractID());
preparedStatement.setString(2, con.getName());
preparedStatement.setInt(3, con.getMobbaseID());
preparedStatement.setInt(4, con.getClassID());
preparedStatement.setInt(5, (con.getVendorDialog() != null) ? con.getVendorDialog().getObjectUUID() : 0);
preparedStatement.setInt(6, con.getIconID());
preparedStatement.setInt(8, con.getObjectUUID());
preparedStatement.setLong(7, con.getAllowedBuildings().toLong());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
}
+250 -250
View File
@@ -27,277 +27,277 @@ public class dbEffectsBaseHandler extends dbHandlerBase {
public dbEffectsBaseHandler() {
}
}
public static ArrayList<EffectsBase> getAllEffectsBase() {
public static ArrayList<EffectsBase> getAllEffectsBase() {
ArrayList<EffectsBase> effectList = new ArrayList<>();
ArrayList<EffectsBase> effectList = new ArrayList<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement prepareStatement = connection.prepareStatement("SELECT * FROM static_power_effectbase ORDER BY `IDString` DESC")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement prepareStatement = connection.prepareStatement("SELECT * FROM static_power_effectbase ORDER BY `IDString` DESC")) {
ResultSet rs = prepareStatement.executeQuery();
ResultSet rs = prepareStatement.executeQuery();
while (rs.next()) {
EffectsBase effectBase = new EffectsBase(rs);
effectList.add(effectBase);
}
} catch (SQLException e) {
Logger.error(e.toString());
}
while (rs.next()) {
EffectsBase effectBase = new EffectsBase(rs);
effectList.add(effectBase);
}
} catch (SQLException e) {
Logger.error(e.toString());
}
return effectList;
}
return effectList;
}
public static void cacheAllEffectModifiers() {
public static void cacheAllEffectModifiers() {
String IDString;
AbstractEffectModifier abstractEffectModifier = null;
String IDString;
AbstractEffectModifier abstractEffectModifier = null;
try (Connection connection = DbManager.getConnection();
PreparedStatement prepareStatement = connection.prepareStatement("SELECT * FROM static_power_effectmod")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement prepareStatement = connection.prepareStatement("SELECT * FROM static_power_effectmod")) {
ResultSet rs = prepareStatement.executeQuery();
ResultSet rs = prepareStatement.executeQuery();
while (rs.next()) {
while (rs.next()) {
IDString = rs.getString("IDString");
EffectsBase effectBase = PowersManager.getEffectByIDString(IDString);
Enum.ModType modifier = Enum.ModType.GetModType(rs.getString("modType"));
IDString = rs.getString("IDString");
EffectsBase effectBase = PowersManager.getEffectByIDString(IDString);
Enum.ModType modifier = Enum.ModType.GetModType(rs.getString("modType"));
//combine item prefix and suffix effect modifiers
//combine item prefix and suffix effect modifiers
abstractEffectModifier = getCombinedModifiers(abstractEffectModifier, rs, effectBase, modifier);
abstractEffectModifier = getCombinedModifiers(abstractEffectModifier, rs, effectBase, modifier);
if (abstractEffectModifier != null) {
if (abstractEffectModifier != null) {
if (EffectsBase.modifiersMap.containsKey(effectBase.getIDString()) == false)
EffectsBase.modifiersMap.put(effectBase.getIDString(), new HashSet<>());
if (EffectsBase.modifiersMap.containsKey(effectBase.getIDString()) == false)
EffectsBase.modifiersMap.put(effectBase.getIDString(), new HashSet<>());
EffectsBase.modifiersMap.get(effectBase.getIDString()).add(abstractEffectModifier);
EffectsBase.modifiersMap.get(effectBase.getIDString()).add(abstractEffectModifier);
}
}
}
}
} catch (Exception e) {
Logger.error(e);
}
} catch (Exception e) {
Logger.error(e);
}
}
}
private static AbstractEffectModifier getCombinedModifiers(AbstractEffectModifier abstractEffectModifier, ResultSet rs, EffectsBase effectBase, Enum.ModType modifier) throws SQLException {
switch (modifier) {
case AdjustAboveDmgCap:
abstractEffectModifier = new AdjustAboveDmgCapEffectModifier(rs);
break;
case Ambidexterity:
abstractEffectModifier = new AmbidexterityEffectModifier(rs);
break;
case AnimOverride:
break;
case ArmorPiercing:
abstractEffectModifier = new ArmorPiercingEffectModifier(rs);
break;
case AttackDelay:
abstractEffectModifier = new AttackDelayEffectModifier(rs);
break;
case Attr:
abstractEffectModifier = new AttributeEffectModifier(rs);
break;
case BlackMantle:
abstractEffectModifier = new BlackMantleEffectModifier(rs);
break;
case BladeTrails:
abstractEffectModifier = new BladeTrailsEffectModifier(rs);
break;
case Block:
abstractEffectModifier = new BlockEffectModifier(rs);
break;
case BlockedPowerType:
abstractEffectModifier = new BlockedPowerTypeEffectModifier(rs);
break;
case CannotAttack:
abstractEffectModifier = new CannotAttackEffectModifier(rs);
break;
case CannotCast:
abstractEffectModifier = new CannotCastEffectModifier(rs);
break;
case CannotMove:
abstractEffectModifier = new CannotMoveEffectModifier(rs);
break;
case CannotTrack:
abstractEffectModifier = new CannotTrackEffectModifier(rs);
break;
case Charmed:
abstractEffectModifier = new CharmedEffectModifier(rs);
break;
case ConstrainedAmbidexterity:
abstractEffectModifier = new ConstrainedAmbidexterityEffectModifier(rs);
break;
case DamageCap:
abstractEffectModifier = new DamageCapEffectModifier(rs);
break;
case DamageShield:
abstractEffectModifier = new DamageShieldEffectModifier(rs);
break;
case DCV:
abstractEffectModifier = new DCVEffectModifier(rs);
break;
case Dodge:
abstractEffectModifier = new DodgeEffectModifier(rs);
break;
case DR:
abstractEffectModifier = new DREffectModifier(rs);
break;
case Durability:
abstractEffectModifier = new DurabilityEffectModifier(rs);
break;
case ExclusiveDamageCap:
abstractEffectModifier = new ExclusiveDamageCapEffectModifier(rs);
break;
case Fade:
abstractEffectModifier = new FadeEffectModifier(rs);
break;
case Fly:
abstractEffectModifier = new FlyEffectModifier(rs);
break;
case Health:
abstractEffectModifier = new HealthEffectModifier(rs);
break;
case HealthFull:
abstractEffectModifier = new HealthFullEffectModifier(rs);
break;
case HealthRecoverRate:
abstractEffectModifier = new HealthRecoverRateEffectModifier(rs);
break;
case IgnoreDamageCap:
abstractEffectModifier = new IgnoreDamageCapEffectModifier(rs);
break;
case IgnorePassiveDefense:
abstractEffectModifier = new IgnorePassiveDefenseEffectModifier(rs);
break;
case ImmuneTo:
abstractEffectModifier = new ImmuneToEffectModifier(rs);
break;
case ImmuneToAttack:
abstractEffectModifier = new ImmuneToAttackEffectModifier(rs);
break;
case ImmuneToPowers:
abstractEffectModifier = new ImmuneToPowersEffectModifier(rs);
break;
case Invisible:
abstractEffectModifier = new InvisibleEffectModifier(rs);
break;
case ItemName:
abstractEffectModifier = new ItemNameEffectModifier(rs);
if (((ItemNameEffectModifier) abstractEffectModifier).name.isEmpty())
break;
if (effectBase != null)
effectBase.setName((((ItemNameEffectModifier) abstractEffectModifier).name));
break;
case Mana:
abstractEffectModifier = new ManaEffectModifier(rs);
break;
case ManaFull:
abstractEffectModifier = new ManaFullEffectModifier(rs);
break;
case ManaRecoverRate:
abstractEffectModifier = new ManaRecoverRateEffectModifier(rs);
break;
case MaxDamage:
abstractEffectModifier = new MaxDamageEffectModifier(rs);
break;
case MeleeDamageModifier:
abstractEffectModifier = new MeleeDamageEffectModifier(rs);
break;
case MinDamage:
abstractEffectModifier = new MinDamageEffectModifier(rs);
break;
case NoMod:
abstractEffectModifier = new NoModEffectModifier(rs);
break;
case OCV:
abstractEffectModifier = new OCVEffectModifier(rs);
break;
case Parry:
abstractEffectModifier = new ParryEffectModifier(rs);
break;
case PassiveDefense:
abstractEffectModifier = new PassiveDefenseEffectModifier(rs);
break;
case PowerCost:
abstractEffectModifier = new PowerCostEffectModifier(rs);
break;
case PowerCostHealth:
abstractEffectModifier = new PowerCostHealthEffectModifier(rs);
break;
case PowerDamageModifier:
abstractEffectModifier = new PowerDamageEffectModifier(rs);
break;
case ProtectionFrom:
abstractEffectModifier = new ProtectionFromEffectModifier(rs);
break;
case Resistance:
abstractEffectModifier = new ResistanceEffectModifier(rs);
break;
case ScaleHeight:
abstractEffectModifier = new ScaleHeightEffectModifier(rs);
break;
case ScaleWidth:
abstractEffectModifier = new ScaleWidthEffectModifier(rs);
break;
case ScanRange:
abstractEffectModifier = new ScanRangeEffectModifier(rs);
break;
case SeeInvisible:
abstractEffectModifier = new SeeInvisibleEffectModifier(rs);
break;
case Silenced:
abstractEffectModifier = new SilencedEffectModifier(rs);
break;
case Skill:
abstractEffectModifier = new SkillEffectModifier(rs);
break;
case Slay:
abstractEffectModifier = new SlayEffectModifier(rs);
break;
case Speed:
abstractEffectModifier = new SpeedEffectModifier(rs);
break;
case SpireBlock:
abstractEffectModifier = new SpireBlockEffectModifier(rs);
break;
case Stamina:
abstractEffectModifier = new StaminaEffectModifier(rs);
break;
case StaminaFull:
abstractEffectModifier = new StaminaFullEffectModifier(rs);
break;
case StaminaRecoverRate:
abstractEffectModifier = new StaminaRecoverRateEffectModifier(rs);
break;
case Stunned:
abstractEffectModifier = new StunnedEffectModifier(rs);
break;
case Value:
abstractEffectModifier = new ValueEffectModifier(rs);
if (effectBase != null) {
ValueEffectModifier valueEffect = (ValueEffectModifier) abstractEffectModifier;
effectBase.setValue(valueEffect.minMod);
}
break;
case WeaponProc:
abstractEffectModifier = new WeaponProcEffectModifier(rs);
break;
case WeaponRange:
abstractEffectModifier = new WeaponRangeEffectModifier(rs);
break;
case WeaponSpeed:
abstractEffectModifier = new WeaponSpeedEffectModifier(rs);
break;
private static AbstractEffectModifier getCombinedModifiers(AbstractEffectModifier abstractEffectModifier, ResultSet rs, EffectsBase effectBase, Enum.ModType modifier) throws SQLException {
switch (modifier) {
case AdjustAboveDmgCap:
abstractEffectModifier = new AdjustAboveDmgCapEffectModifier(rs);
break;
case Ambidexterity:
abstractEffectModifier = new AmbidexterityEffectModifier(rs);
break;
case AnimOverride:
break;
case ArmorPiercing:
abstractEffectModifier = new ArmorPiercingEffectModifier(rs);
break;
case AttackDelay:
abstractEffectModifier = new AttackDelayEffectModifier(rs);
break;
case Attr:
abstractEffectModifier = new AttributeEffectModifier(rs);
break;
case BlackMantle:
abstractEffectModifier = new BlackMantleEffectModifier(rs);
break;
case BladeTrails:
abstractEffectModifier = new BladeTrailsEffectModifier(rs);
break;
case Block:
abstractEffectModifier = new BlockEffectModifier(rs);
break;
case BlockedPowerType:
abstractEffectModifier = new BlockedPowerTypeEffectModifier(rs);
break;
case CannotAttack:
abstractEffectModifier = new CannotAttackEffectModifier(rs);
break;
case CannotCast:
abstractEffectModifier = new CannotCastEffectModifier(rs);
break;
case CannotMove:
abstractEffectModifier = new CannotMoveEffectModifier(rs);
break;
case CannotTrack:
abstractEffectModifier = new CannotTrackEffectModifier(rs);
break;
case Charmed:
abstractEffectModifier = new CharmedEffectModifier(rs);
break;
case ConstrainedAmbidexterity:
abstractEffectModifier = new ConstrainedAmbidexterityEffectModifier(rs);
break;
case DamageCap:
abstractEffectModifier = new DamageCapEffectModifier(rs);
break;
case DamageShield:
abstractEffectModifier = new DamageShieldEffectModifier(rs);
break;
case DCV:
abstractEffectModifier = new DCVEffectModifier(rs);
break;
case Dodge:
abstractEffectModifier = new DodgeEffectModifier(rs);
break;
case DR:
abstractEffectModifier = new DREffectModifier(rs);
break;
case Durability:
abstractEffectModifier = new DurabilityEffectModifier(rs);
break;
case ExclusiveDamageCap:
abstractEffectModifier = new ExclusiveDamageCapEffectModifier(rs);
break;
case Fade:
abstractEffectModifier = new FadeEffectModifier(rs);
break;
case Fly:
abstractEffectModifier = new FlyEffectModifier(rs);
break;
case Health:
abstractEffectModifier = new HealthEffectModifier(rs);
break;
case HealthFull:
abstractEffectModifier = new HealthFullEffectModifier(rs);
break;
case HealthRecoverRate:
abstractEffectModifier = new HealthRecoverRateEffectModifier(rs);
break;
case IgnoreDamageCap:
abstractEffectModifier = new IgnoreDamageCapEffectModifier(rs);
break;
case IgnorePassiveDefense:
abstractEffectModifier = new IgnorePassiveDefenseEffectModifier(rs);
break;
case ImmuneTo:
abstractEffectModifier = new ImmuneToEffectModifier(rs);
break;
case ImmuneToAttack:
abstractEffectModifier = new ImmuneToAttackEffectModifier(rs);
break;
case ImmuneToPowers:
abstractEffectModifier = new ImmuneToPowersEffectModifier(rs);
break;
case Invisible:
abstractEffectModifier = new InvisibleEffectModifier(rs);
break;
case ItemName:
abstractEffectModifier = new ItemNameEffectModifier(rs);
if (((ItemNameEffectModifier) abstractEffectModifier).name.isEmpty())
break;
if (effectBase != null)
effectBase.setName((((ItemNameEffectModifier) abstractEffectModifier).name));
break;
case Mana:
abstractEffectModifier = new ManaEffectModifier(rs);
break;
case ManaFull:
abstractEffectModifier = new ManaFullEffectModifier(rs);
break;
case ManaRecoverRate:
abstractEffectModifier = new ManaRecoverRateEffectModifier(rs);
break;
case MaxDamage:
abstractEffectModifier = new MaxDamageEffectModifier(rs);
break;
case MeleeDamageModifier:
abstractEffectModifier = new MeleeDamageEffectModifier(rs);
break;
case MinDamage:
abstractEffectModifier = new MinDamageEffectModifier(rs);
break;
case NoMod:
abstractEffectModifier = new NoModEffectModifier(rs);
break;
case OCV:
abstractEffectModifier = new OCVEffectModifier(rs);
break;
case Parry:
abstractEffectModifier = new ParryEffectModifier(rs);
break;
case PassiveDefense:
abstractEffectModifier = new PassiveDefenseEffectModifier(rs);
break;
case PowerCost:
abstractEffectModifier = new PowerCostEffectModifier(rs);
break;
case PowerCostHealth:
abstractEffectModifier = new PowerCostHealthEffectModifier(rs);
break;
case PowerDamageModifier:
abstractEffectModifier = new PowerDamageEffectModifier(rs);
break;
case ProtectionFrom:
abstractEffectModifier = new ProtectionFromEffectModifier(rs);
break;
case Resistance:
abstractEffectModifier = new ResistanceEffectModifier(rs);
break;
case ScaleHeight:
abstractEffectModifier = new ScaleHeightEffectModifier(rs);
break;
case ScaleWidth:
abstractEffectModifier = new ScaleWidthEffectModifier(rs);
break;
case ScanRange:
abstractEffectModifier = new ScanRangeEffectModifier(rs);
break;
case SeeInvisible:
abstractEffectModifier = new SeeInvisibleEffectModifier(rs);
break;
case Silenced:
abstractEffectModifier = new SilencedEffectModifier(rs);
break;
case Skill:
abstractEffectModifier = new SkillEffectModifier(rs);
break;
case Slay:
abstractEffectModifier = new SlayEffectModifier(rs);
break;
case Speed:
abstractEffectModifier = new SpeedEffectModifier(rs);
break;
case SpireBlock:
abstractEffectModifier = new SpireBlockEffectModifier(rs);
break;
case Stamina:
abstractEffectModifier = new StaminaEffectModifier(rs);
break;
case StaminaFull:
abstractEffectModifier = new StaminaFullEffectModifier(rs);
break;
case StaminaRecoverRate:
abstractEffectModifier = new StaminaRecoverRateEffectModifier(rs);
break;
case Stunned:
abstractEffectModifier = new StunnedEffectModifier(rs);
break;
case Value:
abstractEffectModifier = new ValueEffectModifier(rs);
if (effectBase != null) {
ValueEffectModifier valueEffect = (ValueEffectModifier) abstractEffectModifier;
effectBase.setValue(valueEffect.minMod);
}
break;
case WeaponProc:
abstractEffectModifier = new WeaponProcEffectModifier(rs);
break;
case WeaponRange:
abstractEffectModifier = new WeaponRangeEffectModifier(rs);
break;
case WeaponSpeed:
abstractEffectModifier = new WeaponSpeedEffectModifier(rs);
break;
}
return abstractEffectModifier;
}
}
return abstractEffectModifier;
}
}
+111 -111
View File
@@ -25,152 +25,152 @@ public class dbItemBaseHandler extends dbHandlerBase {
public dbItemBaseHandler() {
}
}
public void LOAD_BAKEDINSTATS(ItemBase itemBase) {
public void LOAD_BAKEDINSTATS(ItemBase itemBase) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_bakedinstat` WHERE `itemID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_bakedinstat` WHERE `itemID` = ?")) {
preparedStatement.setInt(1, itemBase.getUUID());
ResultSet rs = preparedStatement.executeQuery();
preparedStatement.setInt(1, itemBase.getUUID());
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
if (rs.getBoolean("fromUse"))
itemBase.getUsedStats().put(rs.getInt("token"), rs.getInt("numTrains"));
else
itemBase.getBakedInStats().put(rs.getInt("token"), rs.getInt("numTrains"));
}
} catch (SQLException e) {
Logger.error(e);
}
}
while (rs.next()) {
if (rs.getBoolean("fromUse"))
itemBase.getUsedStats().put(rs.getInt("token"), rs.getInt("numTrains"));
else
itemBase.getBakedInStats().put(rs.getInt("token"), rs.getInt("numTrains"));
}
} catch (SQLException e) {
Logger.error(e);
}
}
public void LOAD_ANIMATIONS(ItemBase itemBase) {
public void LOAD_ANIMATIONS(ItemBase itemBase) {
ArrayList<Integer> tempList = new ArrayList<>();
ArrayList<Integer> tempListOff = new ArrayList<>();
ArrayList<Integer> tempList = new ArrayList<>();
ArrayList<Integer> tempListOff = new ArrayList<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_itembase_animations` WHERE `itemBaseUUID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_itembase_animations` WHERE `itemBaseUUID` = ?")) {
preparedStatement.setInt(1, itemBase.getUUID());
ResultSet rs = preparedStatement.executeQuery();
preparedStatement.setInt(1, itemBase.getUUID());
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
int animation = rs.getInt("animation");
boolean rightHand = rs.getBoolean("rightHand");
while (rs.next()) {
int animation = rs.getInt("animation");
boolean rightHand = rs.getBoolean("rightHand");
if (rightHand)
tempList.add(animation);
else
tempListOff.add(animation);
}
} catch (SQLException e) {
Logger.error(e);
}
if (rightHand)
tempList.add(animation);
else
tempListOff.add(animation);
}
} catch (SQLException e) {
Logger.error(e);
}
itemBase.setAnimations(tempList);
itemBase.setOffHandAnimations(tempListOff);
}
itemBase.setAnimations(tempList);
itemBase.setOffHandAnimations(tempListOff);
}
public void LOAD_ALL_ITEMBASES() {
public void LOAD_ALL_ITEMBASES() {
ItemBase itemBase;
int recordsRead = 0;
ItemBase itemBase;
int recordsRead = 0;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_itembase")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_itembase")) {
ResultSet rs = preparedStatement.executeQuery();
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
recordsRead++;
itemBase = new ItemBase(rs);
ItemBase.addToCache(itemBase);
}
while (rs.next()) {
recordsRead++;
itemBase = new ItemBase(rs);
ItemBase.addToCache(itemBase);
}
} catch (SQLException e) {
Logger.error(e);
}
} catch (SQLException e) {
Logger.error(e);
}
Logger.info("read: " + recordsRead + " cached: " + ItemBase.getUUIDCache().size());
}
Logger.info("read: " + recordsRead + " cached: " + ItemBase.getUUIDCache().size());
}
public HashMap<Integer, ArrayList<Integer>> LOAD_RUNES_FOR_NPC_AND_MOBS() {
public HashMap<Integer, ArrayList<Integer>> LOAD_RUNES_FOR_NPC_AND_MOBS() {
HashMap<Integer, ArrayList<Integer>> runeSets = new HashMap<>();
int runeSetID;
int runeBaseID;
int recordsRead = 0;
HashMap<Integer, ArrayList<Integer>> runeSets = new HashMap<>();
int runeSetID;
int runeBaseID;
int recordsRead = 0;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_runeSet")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_runeSet")) {
ResultSet rs = preparedStatement.executeQuery();
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
while (rs.next()) {
recordsRead++;
recordsRead++;
runeSetID = rs.getInt("runeSet");
runeBaseID = rs.getInt("runeBase");
runeSetID = rs.getInt("runeSet");
runeBaseID = rs.getInt("runeBase");
if (runeSets.get(runeSetID) == null) {
ArrayList<Integer> runeList = new ArrayList<>();
runeList.add(runeBaseID);
runeSets.put(runeSetID, runeList);
} else {
ArrayList<Integer> runeList = runeSets.get(runeSetID);
runeList.add(runeSetID);
runeSets.put(runeSetID, runeList);
}
}
if (runeSets.get(runeSetID) == null) {
ArrayList<Integer> runeList = new ArrayList<>();
runeList.add(runeBaseID);
runeSets.put(runeSetID, runeList);
} else {
ArrayList<Integer> runeList = runeSets.get(runeSetID);
runeList.add(runeSetID);
runeSets.put(runeSetID, runeList);
}
}
} catch (SQLException e) {
Logger.error(e);
return runeSets;
}
} catch (SQLException e) {
Logger.error(e);
return runeSets;
}
Logger.info("read: " + recordsRead + " cached: " + runeSets.size());
return runeSets;
}
Logger.info("read: " + recordsRead + " cached: " + runeSets.size());
return runeSets;
}
public HashMap<Integer, ArrayList<BootySetEntry>> LOAD_BOOTY_FOR_MOBS() {
public HashMap<Integer, ArrayList<BootySetEntry>> LOAD_BOOTY_FOR_MOBS() {
HashMap<Integer, ArrayList<BootySetEntry>> bootySets = new HashMap<>();
BootySetEntry bootySetEntry;
int bootySetID;
int recordsRead = 0;
HashMap<Integer, ArrayList<BootySetEntry>> bootySets = new HashMap<>();
BootySetEntry bootySetEntry;
int bootySetID;
int recordsRead = 0;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_bootySet")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_npc_bootySet")) {
ResultSet rs = preparedStatement.executeQuery();
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
while (rs.next()) {
recordsRead++;
recordsRead++;
bootySetID = rs.getInt("bootySet");
bootySetEntry = new BootySetEntry(rs);
bootySetID = rs.getInt("bootySet");
bootySetEntry = new BootySetEntry(rs);
if (bootySets.get(bootySetID) == null) {
ArrayList<BootySetEntry> bootyList = new ArrayList<>();
bootyList.add(bootySetEntry);
bootySets.put(bootySetID, bootyList);
} else {
ArrayList<BootySetEntry> bootyList = bootySets.get(bootySetID);
bootyList.add(bootySetEntry);
bootySets.put(bootySetID, bootyList);
}
}
} catch (SQLException e) {
Logger.error(e);
return bootySets;
}
if (bootySets.get(bootySetID) == null) {
ArrayList<BootySetEntry> bootyList = new ArrayList<>();
bootyList.add(bootySetEntry);
bootySets.put(bootySetID, bootyList);
} else {
ArrayList<BootySetEntry> bootyList = bootySets.get(bootySetID);
bootyList.add(bootySetEntry);
bootySets.put(bootySetID, bootyList);
}
}
} catch (SQLException e) {
Logger.error(e);
return bootySets;
}
Logger.info("read: " + recordsRead + " cached: " + bootySets.size());
return bootySets;
}
Logger.info("read: " + recordsRead + " cached: " + bootySets.size());
return bootySets;
}
}
+374 -374
View File
@@ -28,529 +28,529 @@ import java.util.concurrent.ConcurrentHashMap;
public class dbWarehouseHandler extends dbHandlerBase {
private static final ConcurrentHashMap<Integer, String> columns = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public dbWarehouseHandler() {
this.localClass = Warehouse.class;
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public static void addObject(ArrayList<AbstractGameObject> list, ResultSet rs) throws SQLException {
String type = rs.getString("type");
switch (type) {
case "building":
Building building = new Building(rs);
DbManager.addToCache(building);
list.add(building);
break;
case "warehouse":
Warehouse warehouse = new Warehouse(rs);
DbManager.addToCache(warehouse);
list.add(warehouse);
break;
}
}
public ArrayList<AbstractGameObject> CREATE_WAREHOUSE(int parentZoneID, int OwnerUUID, String name, int meshUUID,
Vector3fImmutable location, float meshScale, int currentHP,
ProtectionState protectionState, int currentGold, int rank,
DateTime upgradeDate, int blueprintUUID, float w, float rotY) {
private static final ConcurrentHashMap<Integer, String> columns = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
public dbWarehouseHandler() {
this.localClass = Warehouse.class;
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public static void addObject(ArrayList<AbstractGameObject> list, ResultSet rs) throws SQLException {
String type = rs.getString("type");
switch (type) {
case "building":
Building building = new Building(rs);
DbManager.addToCache(building);
list.add(building);
break;
case "warehouse":
Warehouse warehouse = new Warehouse(rs);
DbManager.addToCache(warehouse);
list.add(warehouse);
break;
}
}
public ArrayList<AbstractGameObject> CREATE_WAREHOUSE(int parentZoneID, int OwnerUUID, String name, int meshUUID,
Vector3fImmutable location, float meshScale, int currentHP,
ProtectionState protectionState, int currentGold, int rank,
DateTime upgradeDate, int blueprintUUID, float w, float rotY) {
ArrayList<AbstractGameObject> warehouseList = new ArrayList<>();
ArrayList<AbstractGameObject> warehouseList = new ArrayList<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("CALL `WAREHOUSE_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,? ,? ,?, ?);")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("CALL `WAREHOUSE_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,? ,? ,?, ?);")) {
preparedStatement.setInt(1, parentZoneID);
preparedStatement.setInt(2, OwnerUUID);
preparedStatement.setString(3, name);
preparedStatement.setInt(4, meshUUID);
preparedStatement.setFloat(5, location.x);
preparedStatement.setFloat(6, location.y);
preparedStatement.setFloat(7, location.z);
preparedStatement.setFloat(8, meshScale);
preparedStatement.setInt(9, currentHP);
preparedStatement.setString(10, protectionState.name());
preparedStatement.setInt(11, currentGold);
preparedStatement.setInt(12, rank);
preparedStatement.setInt(1, parentZoneID);
preparedStatement.setInt(2, OwnerUUID);
preparedStatement.setString(3, name);
preparedStatement.setInt(4, meshUUID);
preparedStatement.setFloat(5, location.x);
preparedStatement.setFloat(6, location.y);
preparedStatement.setFloat(7, location.z);
preparedStatement.setFloat(8, meshScale);
preparedStatement.setInt(9, currentHP);
preparedStatement.setString(10, protectionState.name());
preparedStatement.setInt(11, currentGold);
preparedStatement.setInt(12, rank);
if (upgradeDate != null)
preparedStatement.setTimestamp(13, new java.sql.Timestamp(upgradeDate.getMillis()));
else
preparedStatement.setNull(13, java.sql.Types.DATE);
if (upgradeDate != null)
preparedStatement.setTimestamp(13, new java.sql.Timestamp(upgradeDate.getMillis()));
else
preparedStatement.setNull(13, java.sql.Types.DATE);
preparedStatement.setInt(14, blueprintUUID);
preparedStatement.setFloat(15, w);
preparedStatement.setFloat(16, rotY);
preparedStatement.setInt(14, blueprintUUID);
preparedStatement.setFloat(15, w);
preparedStatement.setFloat(16, rotY);
preparedStatement.execute();
ResultSet rs = preparedStatement.getResultSet();
preparedStatement.execute();
ResultSet rs = preparedStatement.getResultSet();
while (rs.next())
addObject(warehouseList, rs);
while (rs.next())
addObject(warehouseList, rs);
while (preparedStatement.getMoreResults()) {
rs = preparedStatement.getResultSet();
while (preparedStatement.getMoreResults()) {
rs = preparedStatement.getResultSet();
while (rs.next())
addObject(warehouseList, rs);
}
} catch (SQLException e) {
Logger.error(e);
}
while (rs.next())
addObject(warehouseList, rs);
}
} catch (SQLException e) {
Logger.error(e);
}
return warehouseList;
}
return warehouseList;
}
public boolean updateLocks(final Warehouse wh, long locks) {
public boolean updateLocks(final Warehouse wh, long locks) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_locks`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_locks`=? WHERE `UID` = ?")) {
preparedStatement.setLong(1, locks);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setLong(1, locks);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateGold(final Warehouse wh, int amount) {
public boolean updateGold(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_gold`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_gold`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateStone(final Warehouse wh, int amount) {
public boolean updateStone(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_stone`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_stone`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateTruesteel(final Warehouse wh, int amount) {
public boolean updateTruesteel(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_truesteel`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_truesteel`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateIron(final Warehouse wh, int amount) {
public boolean updateIron(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_iron`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_iron`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateAdamant(final Warehouse wh, int amount) {
public boolean updateAdamant(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_adamant`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_adamant`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateLumber(final Warehouse wh, int amount) {
public boolean updateLumber(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_lumber`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_lumber`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateOak(final Warehouse wh, int amount) {
public boolean updateOak(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_oak`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_oak`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateBronzewood(final Warehouse wh, int amount) {
public boolean updateBronzewood(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_bronzewood`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_bronzewood`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateMandrake(final Warehouse wh, int amount) {
public boolean updateMandrake(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_mandrake`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_mandrake`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateCoal(final Warehouse wh, int amount) {
public boolean updateCoal(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_coal`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_coal`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateAgate(final Warehouse wh, int amount) {
public boolean updateAgate(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_agate`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_agate`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateDiamond(final Warehouse wh, int amount) {
public boolean updateDiamond(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_diamond`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_diamond`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateOnyx(final Warehouse wh, int amount) {
public boolean updateOnyx(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_onyx`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_onyx`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateAzoth(final Warehouse wh, int amount) {
public boolean updateAzoth(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_azoth`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_azoth`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateOrichalk(final Warehouse wh, int amount) {
public boolean updateOrichalk(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_orichalk`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_orichalk`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateAntimony(final Warehouse wh, int amount) {
public boolean updateAntimony(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_antimony`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_antimony`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateSulfur(final Warehouse wh, int amount) {
public boolean updateSulfur(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_sulfur`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_sulfur`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateQuicksilver(final Warehouse wh, int amount) {
public boolean updateQuicksilver(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_quicksilver`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_quicksilver`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateGalvor(final Warehouse wh, int amount) {
public boolean updateGalvor(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_galvor`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_galvor`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateWormwood(final Warehouse wh, int amount) {
public boolean updateWormwood(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_wormwood`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_wormwood`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateObsidian(final Warehouse wh, int amount) {
public boolean updateObsidian(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_obsidian`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_obsidian`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateBloodstone(final Warehouse wh, int amount) {
public boolean updateBloodstone(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_bloodstone`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_bloodstone`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean updateMithril(final Warehouse wh, int amount) {
public boolean updateMithril(final Warehouse wh, int amount) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_mithril`=? WHERE `UID` = ?")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_warehouse` SET `warehouse_mithril`=? WHERE `UID` = ?")) {
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
preparedStatement.setInt(1, amount);
preparedStatement.setInt(2, wh.getUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public boolean CREATE_TRANSACTION(int warehouseBuildingID, GameObjectType targetType, int targetUUID, TransactionType transactionType, Resource resource, int amount, DateTime date) {
public boolean CREATE_TRANSACTION(int warehouseBuildingID, GameObjectType targetType, int targetUUID, TransactionType transactionType, Resource resource, int amount, DateTime date) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_warehouse_transactions` (`warehouseUID`, `targetType`,`targetUID`, `type`,`resource`,`amount`,`date` ) VALUES (?,?,?,?,?,?,?)")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_warehouse_transactions` (`warehouseUID`, `targetType`,`targetUID`, `type`,`resource`,`amount`,`date` ) VALUES (?,?,?,?,?,?,?)")) {
preparedStatement.setInt(1, amount);
preparedStatement.setLong(1, warehouseBuildingID);
preparedStatement.setString(2, targetType.name());
preparedStatement.setLong(3, targetUUID);
preparedStatement.setString(4, transactionType.name());
preparedStatement.setString(5, resource.name());
preparedStatement.setInt(6, amount);
preparedStatement.setTimestamp(7, new java.sql.Timestamp(date.getMillis()));
preparedStatement.setInt(1, amount);
preparedStatement.setLong(1, warehouseBuildingID);
preparedStatement.setString(2, targetType.name());
preparedStatement.setLong(3, targetUUID);
preparedStatement.setString(4, transactionType.name());
preparedStatement.setString(5, resource.name());
preparedStatement.setInt(6, amount);
preparedStatement.setTimestamp(7, new java.sql.Timestamp(date.getMillis()));
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
public ArrayList<Transaction> GET_TRANSACTIONS_FOR_WAREHOUSE(final int warehouseUUID) {
public ArrayList<Transaction> GET_TRANSACTIONS_FOR_WAREHOUSE(final int warehouseUUID) {
ArrayList<Transaction> transactionsList = new ArrayList<>();
ArrayList<Transaction> transactionsList = new ArrayList<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM dyn_warehouse_transactions WHERE `warehouseUID` = ?;")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM dyn_warehouse_transactions WHERE `warehouseUID` = ?;")) {
preparedStatement.setInt(1, warehouseUUID);
preparedStatement.setInt(1, warehouseUUID);
ResultSet rs = preparedStatement.executeQuery();
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
Transaction transactions = new Transaction(rs);
transactionsList.add(transactions);
}
while (rs.next()) {
Transaction transactions = new Transaction(rs);
transactionsList.add(transactions);
}
} catch (SQLException e) {
Logger.error(e);
}
} catch (SQLException e) {
Logger.error(e);
}
return transactionsList;
}
return transactionsList;
}
public void LOAD_ALL_WAREHOUSES() {
public void LOAD_ALL_WAREHOUSES() {
Warehouse warehouse;
Warehouse warehouse;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_warehouse`.*, `object`.`parent`, `object`.`type` FROM `object` LEFT JOIN `obj_warehouse` ON `object`.`UID` = `obj_warehouse`.`UID` WHERE `object`.`type` = 'warehouse';")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_warehouse`.*, `object`.`parent`, `object`.`type` FROM `object` LEFT JOIN `obj_warehouse` ON `object`.`UID` = `obj_warehouse`.`UID` WHERE `object`.`type` = 'warehouse';")) {
ResultSet rs = preparedStatement.executeQuery();
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
warehouse = new Warehouse(rs);
warehouse.runAfterLoad();
warehouse.loadAllTransactions();
}
while (rs.next()) {
warehouse = new Warehouse(rs);
warehouse.runAfterLoad();
warehouse.loadAllTransactions();
}
} catch (SQLException e) {
Logger.error(e);
}
}
} catch (SQLException e) {
Logger.error(e);
}
}
}
+75 -75
View File
@@ -24,107 +24,107 @@ import java.util.ArrayList;
public class dbZoneHandler extends dbHandlerBase {
public dbZoneHandler() {
this.localClass = Zone.class;
this.localObjectType = Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public dbZoneHandler() {
this.localClass = Zone.class;
this.localObjectType = Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
}
public ArrayList<Zone> GET_ALL_NODES(Zone zone) {
ArrayList<Zone> wsmList = new ArrayList<>();
wsmList.addAll(zone.getNodes());
if (zone.absX == 0.0f) {
zone.absX = zone.getXCoord();
}
if (zone.absY == 0.0f) {
zone.absY = zone.getYCoord();
}
if (zone.absZ == 0.0f) {
zone.absZ = zone.getZCoord();
}
for (Zone child : zone.getNodes()) {
child.absX = child.getXCoord() + zone.absX;
child.absY = child.getYCoord() + zone.absY;
child.absZ = child.getZCoord() + zone.absZ;
wsmList.addAll(this.GET_ALL_NODES(child));
}
return wsmList;
}
public ArrayList<Zone> GET_ALL_NODES(Zone zone) {
ArrayList<Zone> wsmList = new ArrayList<>();
wsmList.addAll(zone.getNodes());
if (zone.absX == 0.0f) {
zone.absX = zone.getXCoord();
}
if (zone.absY == 0.0f) {
zone.absY = zone.getYCoord();
}
if (zone.absZ == 0.0f) {
zone.absZ = zone.getZCoord();
}
for (Zone child : zone.getNodes()) {
child.absX = child.getXCoord() + zone.absX;
child.absY = child.getYCoord() + zone.absY;
child.absZ = child.getZCoord() + zone.absZ;
wsmList.addAll(this.GET_ALL_NODES(child));
}
return wsmList;
}
public Zone GET_BY_UID(long ID) {
public Zone GET_BY_UID(long ID) {
Zone zone = (Zone) DbManager.getFromCache(Enum.GameObjectType.Zone, (int) ID);
Zone zone = (Zone) DbManager.getFromCache(Enum.GameObjectType.Zone, (int) ID);
if (zone != null)
return zone;
if (zone != null)
return zone;
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_zone`.*, `object`.`parent` FROM `object` INNER JOIN `obj_zone` ON `obj_zone`.`UID` = `object`.`UID` WHERE `object`.`UID` = ?;")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_zone`.*, `object`.`parent` FROM `object` INNER JOIN `obj_zone` ON `obj_zone`.`UID` = `object`.`UID` WHERE `object`.`UID` = ?;")) {
preparedStatement.setLong(1, ID);
preparedStatement.setLong(1, ID);
ResultSet rs = preparedStatement.executeQuery();
zone = (Zone) getObjectFromRs(rs);
ResultSet rs = preparedStatement.executeQuery();
zone = (Zone) getObjectFromRs(rs);
} catch (SQLException e) {
Logger.error(e);
}
} catch (SQLException e) {
Logger.error(e);
}
return zone;
}
return zone;
}
public ArrayList<Zone> GET_MAP_NODES(final int objectUUID) {
public ArrayList<Zone> GET_MAP_NODES(final int objectUUID) {
ArrayList<Zone> zoneList = new ArrayList<>();
ArrayList<Zone> zoneList = new ArrayList<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_zone`.*, `object`.`parent` FROM `object` INNER JOIN `obj_zone` ON `obj_zone`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_zone`.*, `object`.`parent` FROM `object` INNER JOIN `obj_zone` ON `obj_zone`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) {
preparedStatement.setLong(1, objectUUID);
preparedStatement.setLong(1, objectUUID);
ResultSet rs = preparedStatement.executeQuery();
zoneList = getObjectsFromRs(rs, 2000);
ResultSet rs = preparedStatement.executeQuery();
zoneList = getObjectsFromRs(rs, 2000);
} catch (SQLException e) {
Logger.error(e);
}
} catch (SQLException e) {
Logger.error(e);
}
return zoneList;
}
return zoneList;
}
public void LOAD_ZONE_EXTENTS() {
public void LOAD_ZONE_EXTENTS() {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_zone_size`;")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_zone_size`;")) {
ResultSet rs = preparedStatement.executeQuery();
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
Vector2f zoneSize = new Vector2f();
int loadNum = rs.getInt("loadNum");
zoneSize.x = rs.getFloat("xRadius");
zoneSize.y = rs.getFloat("zRadius");
ZoneManager._zone_size_data.put(loadNum, zoneSize);
}
while (rs.next()) {
Vector2f zoneSize = new Vector2f();
int loadNum = rs.getInt("loadNum");
zoneSize.x = rs.getFloat("xRadius");
zoneSize.y = rs.getFloat("zRadius");
ZoneManager._zone_size_data.put(loadNum, zoneSize);
}
} catch (SQLException e) {
Logger.error(e);
}
}
} catch (SQLException e) {
Logger.error(e);
}
}
public boolean DELETE_ZONE(final Zone zone) {
public boolean DELETE_ZONE(final Zone zone) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `object` WHERE `UID` = ? AND `type` = 'zone'")) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `object` WHERE `UID` = ? AND `type` = 'zone'")) {
preparedStatement.setInt(1, zone.getObjectUUID());
preparedStatement.setInt(1, zone.getObjectUUID());
return (preparedStatement.executeUpdate() > 0);
return (preparedStatement.executeUpdate() > 0);
} catch (SQLException e) {
Logger.error(e);
}
} catch (SQLException e) {
Logger.error(e);
}
return false;
}
return false;
}
}