return;
}
siegeClan = new SiegeClanObject(SiegeEvent.ATTACKERS, playerClan, 0);
siegeEvent.addObject(SiegeEvent.ATTACKERS, siegeClan);
SiegeClanDAO.getInstance().insert(castle, siegeClan);
player.sendPacket(new CastleSiegeAttackerList(castle));
}
else
{
if (castle.getOwnerId() == 0)
{
return;
}
if (castle.getOwnerId() == playerClan.getClanId())
{
player.sendPacket(SystemMsg.CASTLE_OWNING_CLANS_ARE_AUTOMATICALLY_REGISTERED_ON_THE_DEFENDING_SIDE);
return;
}
if (playerClan.getCastle() > 0)
{
player.sendPacket(SystemMsg.A_CLAN_THAT_OWNS_A_CASTLE_CANNOT_PARTICIPATE_IN_ANOTHER_SIEGE);
return;
}
if (siegeClan != null)
{
player.sendPacket(SystemMsg.YOU_HAVE_ALREADY_REGISTERED_TO_THE_DEFENDER_SIDE_AND_MUST_CANCEL_YOUR_REGISTRATION_BEFORE_SUBMITTING_YOUR_REQUEST);
return;
}
if (playerClan.getLevel() < 5)
{
player.sendPacket(SystemMsg.ONLY_CLANS_OF_LEVEL_5_OR_HIGHER_MAY_REGISTER_FOR_A_CASTLE_SIEGE);
return;
}
if (registeredCastle != null)
{
player.sendPacket(SystemMsg.YOU_HAVE_ALREADY_REQUESTED_A_CASTLE_SIEGE);
return;
}
if (castle.getSiegeDate().getTimeInMillis() == 0)
{
player.sendPacket(SystemMsg.THIS_IS_NOT_THE_TIME_FOR_SIEGE_REGISTRATION_AND_SO_REGISTRATION_AND_CANCELLATION_CANNOT_BE_DONE);
return;
}
if (siegeEvent.isRegistrationOver())
{
player.sendPacket(SystemMsg.YOU_ARE_TOO_LATE_THE_REGISTRATION_PERIOD_IS_OVER);
return;
}
siegeClan = new SiegeClanObject(CastleSiegeEvent.DEFENDERS_WAITING, playerClan, 0);
siegeEvent.addObject(CastleSiegeEvent.DEFENDERS_WAITING, siegeClan);
SiegeClanDAO.getInstance().insert(castle, siegeClan);
player.sendPacket(new CastleSiegeDefenderList(castle));
}
}
else
{
if (siegeClan == null)
{
siegeClan = siegeEvent.getSiegeClan(CastleSiegeEvent.DEFENDERS_REFUSED, playerClan);
}
if (siegeClan == null)
{
player.sendPacket(SystemMsg.YOU_ARE_NOT_YET_REGISTERED_FOR_THE_CASTLE_SIEGE);
return;
}
if (siegeEvent.isRegistrationOver())
{
player.sendPacket(SystemMsg.YOU_ARE_TOO_LATE_THE_REGISTRATION_PERIOD_IS_OVER);
return;
}
siegeEvent.removeObject(siegeClan.getType(), siegeClan);
SiegeClanDAO.getInstance().delete(castle, siegeClan);
if (siegeClan.getType().equals(SiegeEvent.ATTACKERS))
{
player.sendPacket(new CastleSiegeAttackerList(castle));
}
else
{
player.sendPacket(new CastleSiegeDefenderList(castle));
}