|
|
@ -62,7 +62,6 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler { |
|
|
|
Building building; |
|
|
|
Building building; |
|
|
|
|
|
|
|
|
|
|
|
msg = (ManageCityAssetsMsg) baseMsg; |
|
|
|
msg = (ManageCityAssetsMsg) baseMsg; |
|
|
|
|
|
|
|
|
|
|
|
player = SessionManager.getPlayerCharacter(origin); |
|
|
|
player = SessionManager.getPlayerCharacter(origin); |
|
|
|
|
|
|
|
|
|
|
|
if (player == null) |
|
|
|
if (player == null) |
|
|
@ -72,34 +71,21 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler { |
|
|
|
|
|
|
|
|
|
|
|
if (building == null) { |
|
|
|
if (building == null) { |
|
|
|
if (msg.actionType == 14) { |
|
|
|
if (msg.actionType == 14) { |
|
|
|
|
|
|
|
|
|
|
|
Zone zone = ZoneManager.findSmallestZone(player.getLoc()); |
|
|
|
Zone zone = ZoneManager.findSmallestZone(player.getLoc()); |
|
|
|
|
|
|
|
|
|
|
|
if (!zone.isPlayerCity()) { |
|
|
|
if (!zone.isPlayerCity()) { |
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "Unable to find city to command."); |
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "Unable to find city to command."); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
City city = City.GetCityFromCache(zone.getPlayerCityUUID()); |
|
|
|
City city = City.GetCityFromCache(zone.getPlayerCityUUID()); |
|
|
|
|
|
|
|
if (city == null || !city.getGuild().equals(player.getGuild()) || |
|
|
|
if (city == null) { |
|
|
|
(!GuildStatusController.isInnerCouncil(player.getGuildStatus()) && |
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "Unable to find city to command."); |
|
|
|
!GuildStatusController.isGuildLeader(player.getGuildStatus()))) { |
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!city.getGuild().equals(player.getGuild())) { |
|
|
|
|
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "You are not in the correct guild to command this city."); |
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "You are not in the correct guild to command this city."); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!GuildStatusController.isInnerCouncil(player.getGuildStatus()) && !GuildStatusController.isGuildLeader(player.getGuildStatus())) { |
|
|
|
|
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "You must be an Inner Council or Guild leader to access city commands."); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ManageCityAssetsMsg mca = new ManageCityAssetsMsg(player, building); |
|
|
|
ManageCityAssetsMsg mca = new ManageCityAssetsMsg(player, building); |
|
|
|
mca.actionType = 15; |
|
|
|
mca.actionType = 15; |
|
|
|
Dispatch dispatch = Dispatch.borrow(player, mca); |
|
|
|
DispatchMessage.dispatchMsgDispatch(Dispatch.borrow(player, mca), DispatchChannel.SECONDARY); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -111,181 +97,118 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler { |
|
|
|
outMsg.setTargetType(building.getObjectType().ordinal()); |
|
|
|
outMsg.setTargetType(building.getObjectType().ordinal()); |
|
|
|
outMsg.setTargetID(building.getObjectUUID()); |
|
|
|
outMsg.setTargetID(building.getObjectUUID()); |
|
|
|
outMsg.setAssetName(building.getName()); |
|
|
|
outMsg.setAssetName(building.getName()); |
|
|
|
Dispatch dispatch = Dispatch.borrow(player, outMsg); |
|
|
|
DispatchMessage.dispatchMsgDispatch(Dispatch.borrow(player, outMsg), DispatchChannel.SECONDARY); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (msg.actionType == 2 || msg.actionType == 22) { |
|
|
|
switch (msg.actionType) { |
|
|
|
|
|
|
|
case 2: |
|
|
|
if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup() == engine.Enum.BuildingGroup.BANESTONE) { |
|
|
|
case 22: |
|
|
|
|
|
|
|
if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup() == engine.Enum.BuildingGroup.BANESTONE) { |
|
|
|
outMsg.actionType = 18; |
|
|
|
outMsg.actionType = 18; |
|
|
|
outMsg.setTargetType(building.getObjectType().ordinal()); |
|
|
|
outMsg.setTargetType(building.getObjectType().ordinal()); |
|
|
|
outMsg.setTargetID(building.getObjectUUID()); |
|
|
|
outMsg.setTargetID(building.getObjectUUID()); |
|
|
|
|
|
|
|
} else if (BuildingManager.playerCanManage(player, building)) { |
|
|
|
} else if (BuildingManager.playerCanManage(player, building)) { //TODO allow Friends list.
|
|
|
|
configWindowState(player, building, outMsg); |
|
|
|
configWindowState(player, building, outMsg); |
|
|
|
outMsg.actionType = 3; |
|
|
|
outMsg.actionType = 3; |
|
|
|
outMsg.setTargetType(building.getObjectType().ordinal()); |
|
|
|
outMsg.setTargetType(building.getObjectType().ordinal()); |
|
|
|
outMsg.setTargetID(building.getObjectUUID()); |
|
|
|
outMsg.setTargetID(building.getObjectUUID()); |
|
|
|
outMsg.setTargetType3(building.getObjectType().ordinal()); |
|
|
|
outMsg.setTargetType3(building.getObjectType().ordinal()); |
|
|
|
outMsg.setTargetID3(building.getObjectUUID()); |
|
|
|
outMsg.setTargetID3(building.getObjectUUID()); |
|
|
|
outMsg.setUnknown54(1); |
|
|
|
outMsg.setUnknown54(1); |
|
|
|
} else { |
|
|
|
|
|
|
|
// Handle other cases
|
|
|
|
} else { |
|
|
|
if (building.getRank() == -1) { |
|
|
|
|
|
|
|
if (!Bounds.collide(player.getLoc(), building)) { |
|
|
|
if (building.getBlueprintUUID() != 0) |
|
|
|
ErrorPopupMsg.sendErrorPopup(player, 64); |
|
|
|
switch (building.getBlueprint().getBuildingGroup()) { |
|
|
|
return true; |
|
|
|
case SHRINE: |
|
|
|
} |
|
|
|
if (building.getRank() == -1) { |
|
|
|
switch (building.getBlueprint().getBuildingGroup()) { |
|
|
|
if (!Bounds.collide(player.getLoc(), building)) { |
|
|
|
case SHRINE: |
|
|
|
ErrorPopupMsg.sendErrorPopup(player, 64); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Shrine shrine = Shrine.shrinesByBuildingUUID.get(building.getObjectUUID()); |
|
|
|
Shrine shrine = Shrine.shrinesByBuildingUUID.get(building.getObjectUUID()); |
|
|
|
|
|
|
|
if (shrine == null || shrine.getFavors() == 0) { |
|
|
|
if (shrine == null) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (shrine.getFavors() == 0) { |
|
|
|
|
|
|
|
ErrorPopupMsg.sendErrorPopup(player, 166); // There is no more favor in this shrine to loot
|
|
|
|
ErrorPopupMsg.sendErrorPopup(player, 166); // There is no more favor in this shrine to loot
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
BuildingManager.lootBuilding(player, building); |
|
|
|
case WAREHOUSE: |
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case WAREHOUSE: |
|
|
|
|
|
|
|
//TODO check
|
|
|
|
|
|
|
|
if (building.getRank() == -1) { |
|
|
|
|
|
|
|
if (!Bounds.collide(player.getLoc(), building)) { |
|
|
|
|
|
|
|
ErrorPopupMsg.sendErrorPopup(player, 64); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Warehouse warehouse = Warehouse.warehouseByBuildingUUID.get(building.getObjectUUID()); |
|
|
|
Warehouse warehouse = Warehouse.warehouseByBuildingUUID.get(building.getObjectUUID()); |
|
|
|
|
|
|
|
if (warehouse == null || warehouse.isEmpty()) { |
|
|
|
if (warehouse == null) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (warehouse.isEmpty()) { |
|
|
|
|
|
|
|
ErrorPopupMsg.sendErrorPopup(player, 167); // no more resources.
|
|
|
|
ErrorPopupMsg.sendErrorPopup(player, 167); // no more resources.
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
BuildingManager.lootBuilding(player, building); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
AbstractCharacter owner = building.getOwner(); |
|
|
|
|
|
|
|
if (owner == null) { |
|
|
|
|
|
|
|
msg.actionType = 4; |
|
|
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(Dispatch.borrow(player, msg), DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
outMsg.actionType = 4; |
|
|
|
|
|
|
|
outMsg.setTargetType(building.getObjectType().ordinal()); |
|
|
|
|
|
|
|
outMsg.setTargetID(building.getObjectUUID()); |
|
|
|
|
|
|
|
outMsg.setAssetName(building.getName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (building.getRank() == -1) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AbstractCharacter owner = building.getOwner(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//no owner, send building info
|
|
|
|
|
|
|
|
if (owner == null) { |
|
|
|
|
|
|
|
msg.actionType = 4; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dispatch dispatch = Dispatch.borrow(player, msg); |
|
|
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
outMsg.actionType = 4; |
|
|
|
DispatchMessage.dispatchMsgDispatch(Dispatch.borrow(player, outMsg), DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
case 13: |
|
|
|
|
|
|
|
outMsg.actionType = 13; |
|
|
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(Dispatch.borrow(player, outMsg), DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
case 5: |
|
|
|
|
|
|
|
building.setName(msg.getAssetName()); |
|
|
|
|
|
|
|
configWindowState(player, building, outMsg); |
|
|
|
|
|
|
|
outMsg.actionType = 3; |
|
|
|
outMsg.setTargetType(building.getObjectType().ordinal()); |
|
|
|
outMsg.setTargetType(building.getObjectType().ordinal()); |
|
|
|
outMsg.setTargetID(building.getObjectUUID()); |
|
|
|
outMsg.setTargetID(building.getObjectUUID()); |
|
|
|
outMsg.setAssetName(building.getName()); |
|
|
|
outMsg.setTargetType3(GameObjectType.Building.ordinal()); |
|
|
|
|
|
|
|
outMsg.setTargetID3(building.getObjectUUID()); |
|
|
|
} |
|
|
|
outMsg.setAssetName1(building.getName()); |
|
|
|
Dispatch dispatch = Dispatch.borrow(player, outMsg); |
|
|
|
outMsg.setUnknown54(1); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
|
|
|
DispatchMessage.dispatchMsgDispatch(Dispatch.borrow(player, outMsg), DispatchChannel.SECONDARY); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
case 14: |
|
|
|
|
|
|
|
ManageCityAssetsMsg mca = new ManageCityAssetsMsg(player, building); |
|
|
|
|
|
|
|
mca.actionType = 15; |
|
|
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(Dispatch.borrow(player, mca), DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
case 20: |
|
|
|
|
|
|
|
// Handle case 20
|
|
|
|
|
|
|
|
return handleCase20(player, outMsg, building, msg, origin); |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (msg.actionType == 13) { |
|
|
|
private boolean handleCase20(PlayerCharacter player, ManageCityAssetsMsg outMsg, Building building, ManageCityAssetsMsg msg, ClientConnection origin) throws MsgSendException { |
|
|
|
outMsg.actionType = 13; |
|
|
|
Zone baneZone = building.getParentZone(); |
|
|
|
Dispatch dispatch = Dispatch.borrow(player, outMsg); |
|
|
|
if (baneZone == null) |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
City banedCity = City.getCity(baneZone.getPlayerCityUUID()); |
|
|
|
|
|
|
|
if (banedCity == null) |
|
|
|
|
|
|
|
|
|
|
|
//Rename Building.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (msg.actionType == 5) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO we need to check names before allowing
|
|
|
|
|
|
|
|
building.setName(msg.getAssetName()); |
|
|
|
|
|
|
|
configWindowState(player, building, outMsg); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outMsg.actionType = 3; |
|
|
|
|
|
|
|
outMsg.setTargetType(building.getObjectType().ordinal()); |
|
|
|
|
|
|
|
outMsg.setTargetID(building.getObjectUUID()); |
|
|
|
|
|
|
|
outMsg.setTargetType3(GameObjectType.Building.ordinal()); |
|
|
|
|
|
|
|
outMsg.setTargetID3(building.getObjectUUID()); |
|
|
|
|
|
|
|
outMsg.setAssetName1(building.getName()); |
|
|
|
|
|
|
|
outMsg.setUnknown54(1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dispatch dispatch = Dispatch.borrow(player, outMsg); |
|
|
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
Bane bane = banedCity.getBane(); |
|
|
|
//TOL, update city name also
|
|
|
|
if (bane == null || bane.getLiveDate() != null || player.getGuild() != banedCity.getGuild() || !GuildStatusController.isInnerCouncil(player.getGuildStatus())) |
|
|
|
//TODO update city and zone in database
|
|
|
|
|
|
|
|
//TODO update city map data in game server
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (msg.actionType == 14) { |
|
|
|
|
|
|
|
ManageCityAssetsMsg mca = new ManageCityAssetsMsg(player, building); |
|
|
|
|
|
|
|
mca.actionType = 15; |
|
|
|
|
|
|
|
Dispatch dispatch = Dispatch.borrow(player, mca); |
|
|
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
int baneHour = msg.getBaneHour(); |
|
|
|
|
|
|
|
if (baneHour < 16 || baneHour > 24) { |
|
|
|
if (msg.actionType == 20) { |
|
|
|
PlaceAssetMsg.sendPlaceAssetError(origin, 1, "A Serious error has occurred. Please post details for to ensure transaction integrity"); |
|
|
|
|
|
|
|
|
|
|
|
Zone baneZone = building.getParentZone(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (baneZone == null) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
City banedCity = City.getCity(baneZone.getPlayerCityUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (banedCity == null) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bane bane = banedCity.getBane(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bane == null || bane.getLiveDate() != null || player.getGuild() != banedCity.getGuild() || GuildStatusController.isInnerCouncil(player.getGuildStatus()) == false) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int baneHour = msg.getBaneHour(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (baneHour < 16 || baneHour > 24) { |
|
|
|
|
|
|
|
PlaceAssetMsg.sendPlaceAssetError(origin, 1, "A Serious error has occurred. Please post details for to ensure transaction integrity"); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DateTime baneLive = new DateTime(bane.getPlacementDate()); |
|
|
|
|
|
|
|
baneLive = baneHour == 24 ? baneLive.plusDays(3) : baneLive.plusDays(2); |
|
|
|
|
|
|
|
baneLive = baneHour == 24 ? baneLive.hourOfDay().setCopy(0) : baneLive.hourOfDay().setCopy(baneHour); |
|
|
|
|
|
|
|
baneLive = baneLive.minuteOfHour().setCopy(0); |
|
|
|
|
|
|
|
baneLive = baneLive.secondOfMinute().setCopy(1); |
|
|
|
|
|
|
|
bane.setLiveDate(baneLive); |
|
|
|
|
|
|
|
outMsg.actionType = 18; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dispatch dispatch = Dispatch.borrow(player, outMsg); |
|
|
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
DateTime baneLive = new DateTime(bane.getPlacementDate()); |
|
|
|
|
|
|
|
baneLive = baneHour == 24 ? baneLive.plusDays(3) : baneLive.plusDays(2); |
|
|
|
|
|
|
|
baneLive = baneHour == 24 ? baneLive.hourOfDay().setCopy(0) : baneLive.hourOfDay().setCopy(baneHour); |
|
|
|
|
|
|
|
baneLive = baneLive.minuteOfHour().setCopy(0); |
|
|
|
|
|
|
|
baneLive = baneLive.secondOfMinute().setCopy(1); |
|
|
|
|
|
|
|
bane.setLiveDate(baneLive); |
|
|
|
|
|
|
|
outMsg.actionType = 18; |
|
|
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(Dispatch.borrow(player, outMsg), DispatchChannel.SECONDARY); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void configWindowState(PlayerCharacter player, Building building, ManageCityAssetsMsg manageCityAssetsMsg) { |
|
|
|
public void configWindowState(PlayerCharacter player, Building building, ManageCityAssetsMsg manageCityAssetsMsg) { |
|
|
|
|
|
|
|
|
|
|
|
// Tests to turn on upgrade button if a building is not
|
|
|
|
// Tests to turn on upgrade button if a building is not
|
|
|
|