forked from MagicBane/Server
Project cleanup pre merge.
This commit is contained in:
@@ -7,9 +7,6 @@
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
@@ -46,114 +43,114 @@ import engine.util.StringUtils;
|
||||
|
||||
public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public GuildCreationFinalizeHandler() {
|
||||
super(GuildCreationFinalizeMsg.class);
|
||||
}
|
||||
public GuildCreationFinalizeHandler() {
|
||||
super(GuildCreationFinalizeMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player;
|
||||
GuildCreationFinalizeMsg msg;
|
||||
Enum.GuildType charterType;
|
||||
Guild newGuild;
|
||||
Guild playerGuild;
|
||||
ItemBase itemBase;
|
||||
Item charter;
|
||||
Dispatch dispatch;
|
||||
PlayerCharacter player;
|
||||
GuildCreationFinalizeMsg msg;
|
||||
Enum.GuildType charterType;
|
||||
Guild newGuild;
|
||||
Guild playerGuild;
|
||||
ItemBase itemBase;
|
||||
Item charter;
|
||||
Dispatch dispatch;
|
||||
|
||||
msg = (GuildCreationFinalizeMsg) baseMsg;
|
||||
msg = (GuildCreationFinalizeMsg) baseMsg;
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
playerGuild = player.getGuild();
|
||||
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;
|
||||
}
|
||||
if (playerGuild.isEmptyGuild() == false && player.getGuild().getGuildLeaderUUID() == player.getObjectUUID()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.MUST_LEAVE_GUILD);
|
||||
return true;
|
||||
}
|
||||
|
||||
//Validate the Charter
|
||||
//Validate the Charter
|
||||
|
||||
charter = msg.getCharter();
|
||||
charter = msg.getCharter();
|
||||
|
||||
if (charter == null || charter.getOwnerType() != OwnerType.PlayerCharacter || charter.getOwnerID() != player.getObjectUUID()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
if (charter == null || charter.getOwnerType() != OwnerType.PlayerCharacter || charter.getOwnerID() != player.getObjectUUID()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
itemBase = charter.getItemBase();
|
||||
itemBase = charter.getItemBase();
|
||||
|
||||
// Item must be a valid charterType (type 10 in db)
|
||||
// Item must be a valid charterType (type 10 in db)
|
||||
|
||||
if (itemBase == null || (itemBase.getType().equals(ItemType.GUILDCHARTER) == false)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
if (itemBase == null || (itemBase.getType().equals(ItemType.GUILDCHARTER) == false)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
charterType = Enum.GuildType.getGuildTypeFromCharter(itemBase);
|
||||
charterType = Enum.GuildType.getGuildTypeFromCharter(itemBase);
|
||||
|
||||
if (charterType == null){
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
if (charterType == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
//Validate Guild Tags
|
||||
//Validate Guild Tags
|
||||
|
||||
if (!msg.getGuildTag().isValid()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.CREST_RESERVED);
|
||||
return true;
|
||||
}
|
||||
if (!msg.getGuildTag().isValid()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.CREST_RESERVED);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Validation passes. Leave current guild and create new one.
|
||||
// Validation passes. Leave current guild and create new one.
|
||||
|
||||
if (player.getGuild() != null && player.getGuild().isEmptyGuild() == false)
|
||||
player.getGuild().removePlayer(player,GuildHistoryType.LEAVE);
|
||||
if (player.getGuild() != null && player.getGuild().isEmptyGuild() == false)
|
||||
player.getGuild().removePlayer(player, GuildHistoryType.LEAVE);
|
||||
|
||||
int leadershipType = ((msg.getICVoteFlag() << 1) | msg.getMemberVoteFlag());
|
||||
int leadershipType = ((msg.getICVoteFlag() << 1) | msg.getMemberVoteFlag());
|
||||
|
||||
newGuild = new Guild( msg.getName(),null, charterType.ordinal(),
|
||||
charterType.getLeadershipType(leadershipType), msg.getGuildTag(),
|
||||
StringUtils.truncate(msg.getMotto(), 120));
|
||||
newGuild = new Guild(msg.getName(), null, charterType.ordinal(),
|
||||
charterType.getLeadershipType(leadershipType), msg.getGuildTag(),
|
||||
StringUtils.truncate(msg.getMotto(), 120));
|
||||
|
||||
newGuild.setGuildLeaderForCreate(player);
|
||||
newGuild.setGuildLeaderForCreate(player);
|
||||
|
||||
synchronized (this) {
|
||||
if (!DbManager.GuildQueries.IS_NAME_UNIQUE(msg.getName())) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.UNIQUE_NAME);
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (!DbManager.GuildQueries.IS_CREST_UNIQUE(msg.getGuildTag())) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.UNIQUE_CREST);
|
||||
return true;
|
||||
}
|
||||
|
||||
newGuild = DbManager.GuildQueries.SAVE_TO_DATABASE(newGuild);
|
||||
}
|
||||
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);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
if (newGuild == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.FAILURE_TO_SWEAR_GUILD);
|
||||
return true;
|
||||
}
|
||||
|
||||
GuildManager.joinGuild(player, newGuild, GuildHistoryType.CREATE);
|
||||
|
||||
newGuild.setGuildLeader(player);
|
||||
player.setGuildLeader(true);
|
||||
player.setInnerCouncil(true);
|
||||
player.setFullMember(true);
|
||||
player.setGuildTitle(charterType.getNumberOfRanks() - 1);
|
||||
player.getCharItemManager().delete(charter);
|
||||
player.getCharItemManager().updateInventory();
|
||||
player.incVer();
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
DispatchMessage.sendToAllInRange(player, new GuildInfoMsg(player, newGuild, 2));
|
||||
GuildManager.joinGuild(player, newGuild, GuildHistoryType.CREATE);
|
||||
|
||||
ChatManager.chatSystemInfo(player, msg.getName() + " has arrived on Grief server!");
|
||||
newGuild.setGuildLeader(player);
|
||||
player.setGuildLeader(true);
|
||||
player.setInnerCouncil(true);
|
||||
player.setFullMember(true);
|
||||
player.setGuildTitle(charterType.getNumberOfRanks() - 1);
|
||||
player.getCharItemManager().delete(charter);
|
||||
player.getCharItemManager().updateInventory();
|
||||
player.incVer();
|
||||
|
||||
return true;
|
||||
}
|
||||
DispatchMessage.sendToAllInRange(player, new GuildInfoMsg(player, newGuild, 2));
|
||||
|
||||
ChatManager.chatSystemInfo(player, msg.getName() + " has arrived on Grief server!");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user