NPC special price option
This commit is contained in:
@@ -202,12 +202,23 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void updateSpecialPricing(final NPC npc){
|
||||||
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET specialPrice=? WHERE UID = ?")) {
|
||||||
|
preparedStatement.setInt(1, npc.getSpecialPrice());
|
||||||
|
|
||||||
|
preparedStatement.executeUpdate();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
public void updateDatabase(final NPC npc) {
|
public void updateDatabase(final NPC npc) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET npc_name=?, npc_contractID=?, npc_typeID=?, npc_guildID=?,"
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE obj_npc SET npc_name=?, npc_contractID=?, npc_typeID=?, npc_guildID=?,"
|
||||||
+ " npc_spawnX=?, npc_spawnY=?, npc_spawnZ=?, npc_level=? ,"
|
+ " npc_spawnX=?, npc_spawnY=?, npc_spawnZ=?, npc_level=? ,"
|
||||||
+ " npc_buyPercent=?, npc_sellPercent=?, npc_buildingID=?, specialPrice=? WHERE UID = ?")) {
|
+ " npc_buyPercent=?, npc_sellPercent=?, npc_buildingID=? WHERE UID = ?")) {
|
||||||
|
|
||||||
preparedStatement.setString(1, npc.getName());
|
preparedStatement.setString(1, npc.getName());
|
||||||
preparedStatement.setInt(2, (npc.getContract() != null) ? npc.getContract().getObjectUUID() : 0);
|
preparedStatement.setInt(2, (npc.getContract() != null) ? npc.getContract().getObjectUUID() : 0);
|
||||||
@@ -221,7 +232,6 @@ public class dbNPCHandler extends dbHandlerBase {
|
|||||||
preparedStatement.setFloat(10, npc.getSellPercent());
|
preparedStatement.setFloat(10, npc.getSellPercent());
|
||||||
preparedStatement.setInt(11, (npc.getBuilding() != null) ? npc.getBuilding().getObjectUUID() : 0);
|
preparedStatement.setInt(11, (npc.getBuilding() != null) ? npc.getBuilding().getObjectUUID() : 0);
|
||||||
preparedStatement.setInt(12, npc.getDBID());
|
preparedStatement.setInt(12, npc.getDBID());
|
||||||
preparedStatement.setInt(13, npc.getSpecialPrice());
|
|
||||||
|
|
||||||
preparedStatement.executeUpdate();
|
preparedStatement.executeUpdate();
|
||||||
|
|
||||||
|
|||||||
@@ -804,7 +804,7 @@ public class NPC extends AbstractCharacter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateDatabase() {
|
public void updateDatabase() {
|
||||||
DbManager.NPCQueries.updateDatabase(this);
|
DbManager.NPCQueries.updateSpecialPricing(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSymbol() {
|
public int getSymbol() {
|
||||||
|
|||||||
Reference in New Issue
Block a user