db call added

This commit is contained in:
2026-05-07 15:20:24 -04:00
parent 3649c629b7
commit 945f85443d
@@ -38,69 +38,76 @@ public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
AcceptSubInviteMsg msg = (AcceptSubInviteMsg) baseMsg; AcceptSubInviteMsg msg = (AcceptSubInviteMsg) baseMsg;
PlayerCharacter sourcePlayer; PlayerCharacter playerCharacter;
Guild sourceGuild; Guild protectorate;
Guild targetGuild; Guild nation;
Dispatch dispatch; Dispatch dispatch;
// get PlayerCharacter of person sending sub invite // get PlayerCharacter of person sending sub invite
sourcePlayer = SessionManager.getPlayerCharacter(origin); playerCharacter = SessionManager.getPlayerCharacter(origin);
if (sourcePlayer == null) if (playerCharacter == null)
return true; return true;
sourceGuild = sourcePlayer.getGuild(); protectorate = playerCharacter.getGuild();
targetGuild = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID()); nation = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
//must be source guild to sub to //must be source guild to sub to
if (targetGuild == null) { if (nation == null) {
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
return true; return true;
} }
if (sourceGuild == null) { if (protectorate == null) {
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
return true; return true;
} }
if (sourceGuild.equals(targetGuild)) if (protectorate.equals(nation))
return true; return true;
if (GuildStatusController.isGuildLeader(sourcePlayer.getGuildStatus()) == false) { if (GuildStatusController.isGuildLeader(playerCharacter.getGuildStatus()) == false) {
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "Only a guild leader can accept fealty!"); ErrorPopupMsg.sendErrorMsg(playerCharacter, "Only a guild leader can accept fealty!");
return true; return true;
} }
//source guild is limited to 7 subs //source guild is limited to 7 subs
//TODO this should be based on TOL rank //TODO this should be based on TOL rank
if (!targetGuild.canSubAGuild(sourceGuild)) { if (!nation.canSubAGuild(protectorate)) {
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild ErrorPopupMsg.sendErrorPopup(playerCharacter, 45); // Failure to swear guild
return true; return true;
} }
//all tests passed, let's Handle code //all tests passed, let's Handle code
// Update database
if (!DbManager.GuildQueries.UPDATE_PARENT(protectorate.getObjectUUID(), nation.getObjectUUID())) {
ErrorPopupMsg.sendErrorMsg(playerCharacter, "A Serious error has occured. Please post details for to ensure transaction integrity");
return true;
}
//Update Target Guild State. //Update Target Guild State.
sourceGuild.upgradeGuildState(false); protectorate.upgradeGuildState(false);
//Add sub so GuildMaster can Swear in. //Add sub so GuildMaster can Swear in.
ArrayList<Guild> subs = targetGuild.getSubGuildList(); ArrayList<Guild> subs = nation.getSubGuildList();
subs.add(sourceGuild); subs.add(protectorate);
targetGuild.setGuildState(GuildState.Nation);
nation.setGuildState(GuildState.Nation);
//Let's send the message back. //Let's send the message back.
msg.setUnknown02(1); msg.setUnknown02(1);
msg.setResponse("Your guild is now a " + sourceGuild.getGuildState().name() + '.'); msg.setResponse("Your guild is now a " + protectorate.getGuildState().name() + '.');
dispatch = Dispatch.borrow(sourcePlayer, msg); dispatch = Dispatch.borrow(playerCharacter, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
ChatManager.chatSystemInfo(sourcePlayer, "Your guild is now a " + sourceGuild.getGuildState().name() + '.'); ChatManager.chatSystemInfo(playerCharacter, "Your guild is now a " + protectorate.getGuildState().name() + '.');
return true; return true;
} }
} }