Writing string of bitset for contracts.
This commit is contained in:
@@ -106,12 +106,12 @@ public class dbContractHandler extends dbHandlerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateAllowedBuildings(final Contract con, final long slotbitvalue) {
|
public boolean updateAllowedBuildings(final Contract con) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `static_npc_contract` SET `allowedBuildingTypeID`=? WHERE `contractID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `static_npc_contract` SET `slotInBuildings`=? WHERE `contractID`=?")) {
|
||||||
|
|
||||||
preparedStatement.setLong(1, slotbitvalue);
|
preparedStatement.setString(1, mbEnums.asString(con.allowedBuildings));
|
||||||
preparedStatement.setInt(2, con.getContractID());
|
preparedStatement.setInt(2, con.getContractID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
@@ -126,7 +126,7 @@ public class dbContractHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `static_npc_contract` SET `contractID`=?, `name`=?, "
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `static_npc_contract` SET `contractID`=?, `name`=?, "
|
||||||
+ "`mobbaseID`=?, `classID`=?, vendorDialog=?, iconID=?, allowedBuildingTypeID=? WHERE `ID`=?")) {
|
+ "`mobbaseID`=?, `classID`=?, vendorDialog=?, iconID=?, slotInBuildings=? WHERE `ID`=?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, con.getContractID());
|
preparedStatement.setInt(1, con.getContractID());
|
||||||
preparedStatement.setString(2, con.getName());
|
preparedStatement.setString(2, con.getName());
|
||||||
@@ -135,7 +135,7 @@ public class dbContractHandler extends dbHandlerBase {
|
|||||||
preparedStatement.setInt(5, (con.getVendorDialog() != null) ? con.getVendorDialog().getObjectUUID() : 0);
|
preparedStatement.setInt(5, (con.getVendorDialog() != null) ? con.getVendorDialog().getObjectUUID() : 0);
|
||||||
preparedStatement.setInt(6, con.getIconID());
|
preparedStatement.setInt(6, con.getIconID());
|
||||||
preparedStatement.setInt(8, con.getObjectUUID());
|
preparedStatement.setInt(8, con.getObjectUUID());
|
||||||
preparedStatement.setLong(7, mbEnums.toLong(con.getAllowedBuildings()));
|
preparedStatement.setString(7, mbEnums.asString(con.allowedBuildings));
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
|
|||||||
@@ -369,7 +369,8 @@ public class InfoCmd extends AbstractDevCmd {
|
|||||||
output += newline;
|
output += newline;
|
||||||
output += "InventorySet: " + targetNPC.getContract().inventorySet;
|
output += "InventorySet: " + targetNPC.getContract().inventorySet;
|
||||||
output += newline;
|
output += newline;
|
||||||
output += targetNPC.getContract().getAllowedBuildings().toString();
|
Contract contract1 = targetNPC.getContract();
|
||||||
|
output += contract1.allowedBuildings.toString();
|
||||||
output += newline;
|
output += newline;
|
||||||
output += "Extra Rune: " + targetNPC.getContract().getExtraRune();
|
output += "Extra Rune: " + targetNPC.getContract().getExtraRune();
|
||||||
|
|
||||||
@@ -383,7 +384,8 @@ public class InfoCmd extends AbstractDevCmd {
|
|||||||
output += newline;
|
output += newline;
|
||||||
if (mobBase != null) {
|
if (mobBase != null) {
|
||||||
output += newline;
|
output += newline;
|
||||||
output += "Slottable: " + targetNPC.getContract().getAllowedBuildings().toString();
|
Contract contract = targetNPC.getContract();
|
||||||
|
output += "Slottable: " + contract.allowedBuildings.toString();
|
||||||
output += newline;
|
output += newline;
|
||||||
output += "EquipSet: " + targetNPC.getEquipmentSetID();
|
output += "EquipSet: " + targetNPC.getEquipmentSetID();
|
||||||
output += newline;
|
output += newline;
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ package engine.devcmd.cmds;
|
|||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.gameManager.ChatManager;
|
import engine.gameManager.ChatManager;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.mbEnums;
|
|
||||||
import engine.mbEnums.BuildingGroup;
|
import engine.mbEnums.BuildingGroup;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
import engine.util.StringUtils;
|
import engine.util.StringUtils;
|
||||||
@@ -93,7 +92,7 @@ public class SlotNpcCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("LIST")) {
|
if (args[0].equalsIgnoreCase("LIST")) {
|
||||||
|
|
||||||
outString = "Current: " + contract.getAllowedBuildings();
|
outString = "Current: " + contract.allowedBuildings;
|
||||||
|
|
||||||
throwbackInfo(pc, outString);
|
throwbackInfo(pc, outString);
|
||||||
return;
|
return;
|
||||||
@@ -111,9 +110,9 @@ public class SlotNpcCmd extends AbstractDevCmd {
|
|||||||
switch (args[1].toUpperCase()) {
|
switch (args[1].toUpperCase()) {
|
||||||
|
|
||||||
case "ON":
|
case "ON":
|
||||||
contract.getAllowedBuildings().add(buildingGroup);
|
contract.allowedBuildings.add(buildingGroup);
|
||||||
|
|
||||||
if (!DbManager.ContractQueries.updateAllowedBuildings(contract, mbEnums.toLong(contract.getAllowedBuildings()))) {
|
if (!DbManager.ContractQueries.updateAllowedBuildings(contract)) {
|
||||||
Logger.error("Failed to update Database for Contract Allowed buildings");
|
Logger.error("Failed to update Database for Contract Allowed buildings");
|
||||||
ChatManager.chatSystemError(pc, "Failed to update Database for Contract Allowed buildings. ");
|
ChatManager.chatSystemError(pc, "Failed to update Database for Contract Allowed buildings. ");
|
||||||
return;
|
return;
|
||||||
@@ -122,8 +121,9 @@ public class SlotNpcCmd extends AbstractDevCmd {
|
|||||||
throwbackInfo(pc, "SlotNpc " + buildingGroup.name() + " added to npc");
|
throwbackInfo(pc, "SlotNpc " + buildingGroup.name() + " added to npc");
|
||||||
break;
|
break;
|
||||||
case "OFF":
|
case "OFF":
|
||||||
contract.getAllowedBuildings().remove(buildingGroup);
|
contract.allowedBuildings.remove(buildingGroup);
|
||||||
if (!DbManager.ContractQueries.updateAllowedBuildings(contract, mbEnums.toLong(contract.getAllowedBuildings()))) {
|
|
||||||
|
if (!DbManager.ContractQueries.updateAllowedBuildings(contract)) {
|
||||||
Logger.error("Failed to update Database for Contract Allowed buildings");
|
Logger.error("Failed to update Database for Contract Allowed buildings");
|
||||||
ChatManager.chatSystemError(pc, "Failed to update Database for Contract Allowed buildings. ");
|
ChatManager.chatSystemError(pc, "Failed to update Database for Contract Allowed buildings. ");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class Contract extends AbstractGameObject {
|
|||||||
private ArrayList<Integer> npcModSuffixTable = new ArrayList<>();
|
private ArrayList<Integer> npcModSuffixTable = new ArrayList<>();
|
||||||
private ArrayList<Byte> itemModTable = new ArrayList<>();
|
private ArrayList<Byte> itemModTable = new ArrayList<>();
|
||||||
private ArrayList<Item> sellInventory = new ArrayList<>();
|
private ArrayList<Item> sellInventory = new ArrayList<>();
|
||||||
private EnumSet<mbEnums.BuildingGroup> allowedBuildings;
|
public EnumSet<mbEnums.BuildingGroup> allowedBuildings;
|
||||||
private ArrayList<Integer> buyItemType = new ArrayList<>();
|
private ArrayList<Integer> buyItemType = new ArrayList<>();
|
||||||
private ArrayList<Integer> buySkillToken = new ArrayList<>();
|
private ArrayList<Integer> buySkillToken = new ArrayList<>();
|
||||||
private ArrayList<Integer> buyUnknownToken = new ArrayList<>();
|
private ArrayList<Integer> buyUnknownToken = new ArrayList<>();
|
||||||
@@ -89,6 +89,8 @@ public class Contract extends AbstractGameObject {
|
|||||||
this.equipmentSet = rs.getInt("equipSetID");
|
this.equipmentSet = rs.getInt("equipSetID");
|
||||||
this.inventorySet = rs.getInt("inventorySet");
|
this.inventorySet = rs.getInt("inventorySet");
|
||||||
|
|
||||||
|
DbManager.ContractQueries.updateAllowedBuildings(this);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String menuoptions = rs.getString("menuoptions");
|
String menuoptions = rs.getString("menuoptions");
|
||||||
|
|
||||||
@@ -220,10 +222,6 @@ public class Contract extends AbstractGameObject {
|
|||||||
DbManager.ContractQueries.updateDatabase(this);
|
DbManager.ContractQueries.updateDatabase(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnumSet<mbEnums.BuildingGroup> getAllowedBuildings() {
|
|
||||||
return allowedBuildings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Integer> getBuyItemType() {
|
public ArrayList<Integer> getBuyItemType() {
|
||||||
return this.buyItemType;
|
return this.buyItemType;
|
||||||
}
|
}
|
||||||
@@ -254,7 +252,4 @@ public class Contract extends AbstractGameObject {
|
|||||||
return (this.allowedBuildings.contains(building.getBlueprint().getBuildingGroup()));
|
return (this.allowedBuildings.contains(building.getBlueprint().getBuildingGroup()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEquipmentSet() {
|
|
||||||
return equipmentSet;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1160,7 +1160,7 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed {
|
|||||||
// Setup equipset for contract
|
// Setup equipset for contract
|
||||||
|
|
||||||
if (this.contract != null)
|
if (this.contract != null)
|
||||||
this.equipmentSetID = this.contract.getEquipmentSet();
|
this.equipmentSetID = this.contract.equipmentSet;
|
||||||
|
|
||||||
// Mobiles default to the building guild.
|
// Mobiles default to the building guild.
|
||||||
|
|
||||||
|
|||||||
@@ -162,8 +162,9 @@ public class NPC extends AbstractCharacter {
|
|||||||
|
|
||||||
//838, 950, 1051, 1181, 1251, 1351, 1451, 1501, 1526, 1551, 980101,
|
//838, 950, 1051, 1181, 1251, 1351, 1451, 1501, 1526, 1551, 980101,
|
||||||
|
|
||||||
return contract.getAllowedBuildings().contains(BuildingGroup.WALLCORNER) ||
|
if (contract.allowedBuildings.contains(BuildingGroup.WALLCORNER))
|
||||||
contract.getAllowedBuildings().contains(BuildingGroup.WALLSTRAIGHTTOWER);
|
return true;
|
||||||
|
return contract.allowedBuildings.contains(BuildingGroup.WALLSTRAIGHTTOWER);
|
||||||
}
|
}
|
||||||
|
|
||||||
//This method restarts an upgrade timer when a building is loaded from the database.
|
//This method restarts an upgrade timer when a building is loaded from the database.
|
||||||
|
|||||||
Reference in New Issue
Block a user