|
|
|
@ -289,48 +289,170 @@ public class Warehouse extends AbstractWorldObject {
@@ -289,48 +289,170 @@ public class Warehouse extends AbstractWorldObject {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public synchronized boolean deposit(PlayerCharacter pc, Item resource, int amount, boolean removeFromInventory, boolean transaction) { |
|
|
|
|
|
|
|
|
|
ClientConnection origin = pc.getClientConnection(); |
|
|
|
|
if (origin == null || amount < 0 || resource == null) { |
|
|
|
|
if (amount < 0) Logger.info(pc.getFirstName() + " Attempting to Dupe!!!!!!"); |
|
|
|
|
if (origin == null) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (amount < 0) { |
|
|
|
|
Logger.info(pc.getFirstName() + " Attempting to Dupe!!!!!!"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ItemBase ib = resource.getItemBase(); |
|
|
|
|
if (ib == null) return false; |
|
|
|
|
|
|
|
|
|
Integer currentResourceAmount = this.resources.get(ib); |
|
|
|
|
if (currentResourceAmount == null) return false; |
|
|
|
|
if (ib == null) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (this.resources.get(ib) == null) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
CharacterItemManager itemMan = pc.getCharItemManager(); |
|
|
|
|
if (itemMan == null || !itemMan.doesCharOwnThisItem(resource.getObjectUUID())) return false; |
|
|
|
|
|
|
|
|
|
if (itemMan == null) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (itemMan.getGoldTrading() > 0) { |
|
|
|
|
ErrorPopupMsg.sendErrorPopup(pc, 195); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!resource.validForInventory(origin, pc, itemMan) || resource.getNumOfItems() < amount) return false; |
|
|
|
|
|
|
|
|
|
int newAmount = currentResourceAmount + amount; |
|
|
|
|
Integer maxResourceAmount = Warehouse.getMaxResources().get(ib.getUUID()); |
|
|
|
|
if (newAmount > (maxResourceAmount != null ? maxResourceAmount : Integer.MAX_VALUE)) { |
|
|
|
|
// ChatManager.chatSystemInfo(pc, "The Warehouse is at its maximum for this type of resource.");
|
|
|
|
|
if (!itemMan.doesCharOwnThisItem(resource.getObjectUUID())) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (!resource.validForInventory(origin, pc, itemMan)) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (resource.getNumOfItems() < amount) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
int oldAmount = resources.get(ib); |
|
|
|
|
|
|
|
|
|
int newAmount = oldAmount + amount; |
|
|
|
|
|
|
|
|
|
if (newAmount > Warehouse.getMaxResources().get(ib.getUUID())) { |
|
|
|
|
//ChatManager.chatSystemInfo(pc, "The Warehouse is at it's maximum for this type of resource.");
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (removeFromInventory) { |
|
|
|
|
if (!removeFromInventory(itemMan, ib, amount, pc)) return false; |
|
|
|
|
if (ib.getUUID() == 7) { |
|
|
|
|
|
|
|
|
|
if (itemMan.getGoldInventory().getNumOfItems() - amount < 0) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (itemMan.getGoldInventory().getNumOfItems() - amount > MBServerStatics.PLAYER_GOLD_LIMIT) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (!itemMan.modifyInventoryGold(-amount)) { |
|
|
|
|
//ChatManager.chatSystemError(pc, "You do not have this Gold.");
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UpdateGoldMsg ugm = new UpdateGoldMsg(pc); |
|
|
|
|
ugm.configure(); |
|
|
|
|
Dispatch dispatch = Dispatch.borrow(pc, ugm); |
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
|
|
itemMan.updateInventory(); |
|
|
|
|
if (!updateDatabase(ib.getUUID(), newAmount)) return false; |
|
|
|
|
|
|
|
|
|
this.resources.put(ib, newAmount); |
|
|
|
|
} else { |
|
|
|
|
itemMan.delete(resource); |
|
|
|
|
itemMan.updateInventory(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
itemMan.updateInventory(); |
|
|
|
|
int itemID = ib.getUUID(); |
|
|
|
|
boolean worked = false; |
|
|
|
|
switch (itemID) { |
|
|
|
|
case 7: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateGold(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580000: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateStone(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580001: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateTruesteel(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580002: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateIron(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580003: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateAdamant(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580004: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateLumber(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580005: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateOak(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580006: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateBronzewood(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580007: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateMandrake(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580008: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateCoal(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580009: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateAgate(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580010: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateDiamond(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580011: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateOnyx(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580012: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateAzoth(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580013: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateOrichalk(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580014: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateAntimony(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580015: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateSulfur(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580016: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateQuicksilver(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580017: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateGalvor(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580018: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateWormwood(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580019: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateObsidian(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580020: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateBloodstone(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
case 1580021: |
|
|
|
|
worked = DbManager.WarehouseQueries.updateMithril(this, newAmount); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!worked) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (transaction) { |
|
|
|
|
Resource resourceType = getResourceType(resource); |
|
|
|
|
resources.put(ib, newAmount); |
|
|
|
|
|
|
|
|
|
Resource resourceType; |
|
|
|
|
|
|
|
|
|
if (resource.getItemBase().getType().equals(engine.Enum.ItemType.GOLD)) |
|
|
|
|
resourceType = Resource.GOLD; |
|
|
|
|
else |
|
|
|
|
resourceType = Resource.valueOf(resource.getItemBase().getName().toUpperCase()); |
|
|
|
|
|
|
|
|
|
if (transaction) |
|
|
|
|
this.AddTransactionToWarehouse(pc.getObjectType(), pc.getObjectUUID(), TransactionType.DEPOSIT, resourceType, amount); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|