Deed placement (ObjectActionMsgHandler, PlaceAssetMsgHandler) reads deed_structure_id from DeedTemplate._deeds. The deed, employment contract and charter type checks (PlaceAssetMsgHandler, ActivateNPCMsgHandler, GuildCreationFinalizeHandler, UseCharterMsg, Item.serialize) read item_type through the cache template bridge. Charters go through the shared getter rather than _deeds because template 545 "Charter" is a CHARTER in the ITEM folder. Parity (offline, static_item_templates vs COBJECTS, scripts/p13.py, 881 templates: all 880 DEED plus ITEM 545): 0 differences in item_type and deed_structure_id. Every DB DEED, EMPLOYMENTCONTRACT, PETTOTEM and FURNITUREDEED id is in the DEED folder. No value changes expected. No pet totem or furniture deed consumer reads template fields, so neither changes. JSON-Refactor-Plan Task 1.3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
140 lines
5.2 KiB
Java
140 lines
5.2 KiB
Java
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
// Magicbane Emulator Project © 2013 - 2026
|
|
// https://www.magicbane.com
|
|
|
|
|
|
package engine.net.client.handlers;
|
|
|
|
import engine.gameManager.*;
|
|
import engine.mbEnums;
|
|
import engine.mbEnums.DispatchChannel;
|
|
import engine.mbEnums.GuildHistoryType;
|
|
import engine.mbEnums.ItemType;
|
|
import engine.mbEnums.OwnerType;
|
|
import engine.net.Dispatch;
|
|
import engine.net.client.ClientConnection;
|
|
import engine.net.client.msg.ClientNetMsg;
|
|
import engine.net.client.msg.ErrorPopupMsg;
|
|
import engine.net.client.msg.guild.GuildCreationFinalizeMsg;
|
|
import engine.net.client.msg.guild.GuildInfoMsg;
|
|
import engine.objects.Guild;
|
|
import engine.objects.Item;
|
|
import engine.objects.PlayerCharacter;
|
|
import engine.util.StringUtils;
|
|
|
|
public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
|
|
|
|
public GuildCreationFinalizeHandler() {
|
|
super();
|
|
}
|
|
|
|
@Override
|
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) {
|
|
|
|
PlayerCharacter player;
|
|
GuildCreationFinalizeMsg msg;
|
|
mbEnums.GuildCharterType charterType;
|
|
Guild newGuild;
|
|
Guild playerGuild;
|
|
|
|
Item charter;
|
|
Dispatch dispatch;
|
|
|
|
msg = (GuildCreationFinalizeMsg) baseMsg;
|
|
|
|
player = SessionManager.getPlayerCharacter(origin);
|
|
playerGuild = player.getGuild();
|
|
|
|
if (playerGuild.isEmptyGuild() == false && player.getGuild().getGuildLeaderUUID() == player.getObjectUUID()) {
|
|
ErrorPopupMsg.sendErrorPopup(player, GuildManager.MUST_LEAVE_GUILD);
|
|
return true;
|
|
}
|
|
|
|
//Validate the Charter
|
|
|
|
charter = msg.getCharter();
|
|
|
|
if (charter == null || charter.ownerType != OwnerType.PlayerCharacter || charter.getOwnerID() != player.getObjectUUID()) {
|
|
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
|
return true;
|
|
}
|
|
|
|
// Item must be a valid charterType (type 10 in db)
|
|
|
|
if (charter == null || (charter.template.cacheTemplate.getItemType().equals(ItemType.CHARTER) == false)) {
|
|
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
|
return true;
|
|
}
|
|
|
|
charterType = mbEnums.GuildCharterType.templateLookup.get(charter.templateID);
|
|
|
|
if (charterType == null) {
|
|
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
|
return true;
|
|
}
|
|
|
|
//Validate Guild Tags
|
|
|
|
if (!msg.getGuildTag().isValid()) {
|
|
ErrorPopupMsg.sendErrorPopup(player, GuildManager.CREST_RESERVED);
|
|
return true;
|
|
}
|
|
|
|
// Validation passes. Leave current guild and create new one.
|
|
|
|
if (player.getGuild() != null && player.getGuild().isEmptyGuild() == false)
|
|
player.getGuild().removePlayer(player, GuildHistoryType.LEAVE);
|
|
|
|
int leadershipType = ((msg.getICVoteFlag() << 1) | msg.getMemberVoteFlag());
|
|
|
|
newGuild = new Guild(msg.getName(), null, charterType,
|
|
charterType.getLeadershipType(leadershipType), msg.getGuildTag(),
|
|
StringUtils.truncate(msg.getMotto(), 120));
|
|
|
|
newGuild.setGuildLeaderForCreate(player);
|
|
|
|
synchronized (this) {
|
|
if (!DbManager.GuildQueries.IS_NAME_UNIQUE(msg.getName())) {
|
|
ErrorPopupMsg.sendErrorPopup(player, GuildManager.UNIQUE_NAME);
|
|
return true;
|
|
}
|
|
|
|
if (!DbManager.GuildQueries.IS_CREST_UNIQUE(msg.getGuildTag())) {
|
|
ErrorPopupMsg.sendErrorPopup(player, GuildManager.UNIQUE_CREST);
|
|
return true;
|
|
}
|
|
|
|
newGuild = DbManager.GuildQueries.SAVE_TO_DATABASE(newGuild);
|
|
}
|
|
|
|
if (newGuild == null) {
|
|
ErrorPopupMsg.sendErrorPopup(player, GuildManager.FAILURE_TO_SWEAR_GUILD);
|
|
return true;
|
|
}
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
DispatchManager.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
|
|
|
GuildManager.joinGuild(player, newGuild, GuildHistoryType.CREATE);
|
|
|
|
newGuild.setGuildLeader(player);
|
|
player.setGuildLeader(true);
|
|
player.setInnerCouncil(true);
|
|
player.setFullMember(true);
|
|
player.setGuildTitle(charterType.getNumberOfRanks() - 1);
|
|
player.charItemManager.delete(charter);
|
|
player.charItemManager.updateInventory();
|
|
player.incVer();
|
|
|
|
DispatchManager.sendToAllInRange(player, new GuildInfoMsg(player, newGuild, 2));
|
|
|
|
ChatManager.chatSystemInfo(player, msg.getName() + " has arrived on Grief server!");
|
|
|
|
return true;
|
|
}
|
|
}
|