if (!canBypassCheck(player, this))
{
return;
}
Fortress fortress = getFortress();
FortressSiegeEvent siegeEvent = fortress.getSiegeEvent();
if (command.equalsIgnoreCase("register"))
{
Clan clan = player.getClan();
if (clan == null)
{
showChatWindow(player, "residence2/fortress/fortress_ordery002.htm");
return;
}
if (clan.getHasFortress() == fortress.getId())
{
showChatWindow(player, "residence2/fortress/fortress_ordery014.htm", "%clan_name%", clan.getName());
return;
}
if (!player.hasPrivilege(Privilege.CS_FS_SIEGE_WAR))
{
showChatWindow(player, "residence2/fortress/fortress_ordery012.htm");
return;
}
if (clan.getCastle() > 0)
{
Castle relatedCastle = null;
for (Castle castle : fortress.getRelatedCastles())
{
if (castle.getId() == clan.getCastle())
{
relatedCastle = castle;
}
}
if (relatedCastle != null)
{
if (fortress.getContractState() == Fortress.CONTRACT_WITH_CASTLE)
{
showChatWindow(player, "residence2/fortress/fortress_ordery022.htm");
return;
}
if (relatedCastle.getSiegeEvent().isRegistrationOver())
{
showChatWindow(player, "residence2/fortress/fortress_ordery022.htm");
return;
}
}
else
{
showChatWindow(player, "residence2/fortress/fortress_ordery021.htm");
return;
}
}
int attackersSize = siegeEvent.getObjects(SiegeEvent.ATTACKERS).size();
if (attackersSize == 0)
{
if (!player.consumeItem(ItemTemplate.ITEM_ID_ADENA, 250000L))
{
showChatWindow(player, "residence2/fortress/fortress_ordery003.htm");
return;
}
}
SiegeClanObject siegeClan = siegeEvent.getSiegeClan(SiegeEvent.ATTACKERS, clan);
if (siegeClan != null)
{
showChatWindow(player, "residence2/fortress/fortress_ordery007.htm");
return;
}
for (Fortress $ : ResidenceHolder.getInstance().getResidenceList(Fortress.class))
{
if ($.getSiegeEvent().getSiegeClan(SiegeEvent.ATTACKERS, clan) != null)
{
showChatWindow(player, "residence2/fortress/fortress_ordery006.htm");
return;
}
}
if ((clan.getHasFortress() > 0) && (fortress.getSiegeDate().getTimeInMillis() > 0))
{
showChatWindow(player, "residence2/fortress/fortress_ordery006.htm");
return;
}