Handler created for ViewResourcesMsg

This commit is contained in:
2024-03-29 06:14:19 -04:00
parent fbec206389
commit 80c11db80b
8 changed files with 83 additions and 48 deletions
+5 -35
View File
@@ -22,15 +22,16 @@ import engine.net.NetMsgHandler;
import engine.net.client.handlers.AbstractClientMsgHandler;
import engine.net.client.msg.*;
import engine.net.client.msg.chat.AbstractChatMsg;
import engine.objects.*;
import engine.objects.AbstractCharacter;
import engine.objects.Mob;
import engine.objects.NPC;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
import engine.server.world.WorldServer;
import engine.session.Session;
import engine.util.StringUtils;
import org.pmw.tinylog.Logger;
import java.sql.SQLException;
/**
* @author:
* @summary: This class is the mainline router for application protocol
@@ -167,34 +168,6 @@ public class ClientMessagePump implements NetMsgHandler {
}
private static void ViewResourcesMessage(ViewResourcesMessage msg, ClientConnection origin) throws SQLException {
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
if (player == null)
return;
Guild guild = player.getGuild();
City city = guild.getOwnedCity();
if (city == null)
return;
Building warehouse = BuildingManager.getBuilding(city.getWarehouseBuildingID());
if (warehouse == null)
return;
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
vrm.setWarehouseBuilding(warehouse);
vrm.setGuild(player.getGuild());
vrm.configure();
Dispatch dispatch = Dispatch.borrow(player, vrm);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
}
protected static void petAttack(PetAttackMsg msg, ClientConnection conn) throws MsgSendException {
PlayerCharacter pc = SessionManager.getPlayerCharacter(conn);
@@ -337,9 +310,6 @@ public class ClientMessagePump implements NetMsgHandler {
break;
case OPENVAULT:
break;
case VIEWRESOURCES:
ViewResourcesMessage((ViewResourcesMessage) msg, origin);
break;
case RAISEATTR:
modifyStat((ModifyStatMsg) msg, origin);
break;
@@ -423,7 +393,7 @@ public class ClientMessagePump implements NetMsgHandler {
}
} catch (MsgSendException | SQLException e) {
} catch (Exception e) {
Logger.error("handler for " + protocolMsg + " failed: " + e);
return false;
}