{
try
{
if(_isFree)
return;
L2Clan Clan = ClanTable.getInstance().getClan(getOwnerId());
if (ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().getAdena() >= getLease())
{
if(_paidUntil != 0)
while(_paidUntil<System.currentTimeMillis())_paidUntil += _chRate;
else
_paidUntil = System.currentTimeMillis()+_chRate;
ClanTable.getInstance().getClan(getOwnerId()).getWarehouse().destroyItemByItemId("CH_rental_fee", 57, getLease(), null, null);
if (Config.DEBUG)
_log.warning("deducted "+getLease()+" adena from "+getName()+" owner's cwh for ClanHall _paidUntil"+_paidUntil);
ThreadPoolManager.getInstance().scheduleGeneral(new FeeTask(), _paidUntil-System.currentTimeMillis());
_paid = true;
updateDb();
}
else
{
_paid = false;
if(System.currentTimeMillis()>_paidUntil+_chRate){
if(GameServer.gameServer.getCHManager() != null && GameServer.gameServer.getCHManager().loaded()){
AuctionManager.getInstance().initNPC(getId());
ClanHallManager.getInstance().setFree(getId());
Clan.broadcastToOnlineMembers(new SystemMessage(SystemMessageId.THE_CLAN_HALL_FEE_IS_ONE_WEEK_OVERDUE_THEREFORE_THE_CLAN_HALL_OWNERSHIP_HAS_BEEN_REVOKED));
}else
ThreadPoolManager.getInstance().scheduleGeneral(new FeeTask(), 3000);
}else{
updateDb();
SystemMessage sm = new SystemMessage(SystemMessageId.PAYMENT_FOR_YOUR_CLAN_HALL_HAS_NOT_BEEN_MADE_PLEASE_MAKE_PAYMENT_TO_YOUR_CLAN_WAREHOUSE_BY_S1_TOMORROW);
sm.addNumber(getLease());
Clan.broadcastToOnlineMembers(sm);
if(System.currentTimeMillis()+(1000*60*60*24)<=_paidUntil+_chRate)
ThreadPoolManager.getInstance().scheduleGeneral(new FeeTask(), System.currentTimeMillis()+(1000*60*60*24));
else
ThreadPoolManager.getInstance().scheduleGeneral(new FeeTask(), (_paidUntil+_chRate)-System.currentTimeMillis());