Exemplo n.º 1
0
 /**
  * Method updateOwnerInDB.
  *
  * @param clan Clan
  */
 private void updateOwnerInDB(Clan clan) {
   _owner = clan;
   Connection con = null;
   PreparedStatement statement = null;
   try {
     con = DatabaseFactory.getInstance().getConnection();
     statement =
         con.prepareStatement("UPDATE clan_data SET hasFortress=0 WHERE hasFortress=? LIMIT 1");
     statement.setInt(1, getId());
     statement.execute();
     DbUtils.close(statement);
     if (clan != null) {
       statement =
           con.prepareStatement("UPDATE clan_data SET hasFortress=? WHERE clan_id=? LIMIT 1");
       statement.setInt(1, getId());
       statement.setInt(2, getOwnerId());
       statement.execute();
       clan.broadcastClanStatus(true, false, false);
     }
   } catch (Exception e) {
     _log.error("", e);
   } finally {
     DbUtils.closeQuietly(con, statement);
   }
 }
  /** Method runImpl. */
  @Override
  protected void runImpl() {
    Player activeChar = getClient().getActiveChar();

    if (activeChar == null) {
      return;
    }

    Clan clan = activeChar.getClan();

    if (clan != null) {
      UnitMember cm = clan.getAnyMember(_target);

      if (cm != null) {
        activeChar.sendPacket(new PledgeReceivePowerInfo(cm));
      }
    }
  }
Exemplo n.º 3
0
 /**
  * Method changeOwner.
  *
  * @param clan Clan
  */
 @Override
 public void changeOwner(Clan clan) {
   if (clan != null) {
     if (clan.getHasFortress() != 0) {
       Fortress oldFortress =
           ResidenceHolder.getInstance().getResidence(Fortress.class, clan.getHasFortress());
       if (oldFortress != null) {
         oldFortress.changeOwner(null);
       }
     }
     if (clan.getCastle() != 0) {
       Castle oldCastle =
           ResidenceHolder.getInstance().getResidence(Castle.class, clan.getCastle());
       if (oldCastle != null) {
         oldCastle.changeOwner(null);
       }
     }
   }
   if ((getOwnerId() > 0) && ((clan == null) || (clan.getClanId() != getOwnerId()))) {
     removeSkills();
     Clan oldOwner = getOwner();
     if (oldOwner != null) {
       oldOwner.setHasFortress(0);
     }
     cancelCycleTask();
     clearFacility();
   }
   if (clan != null) {
     clan.setHasFortress(getId());
   }
   updateOwnerInDB(clan);
   rewardSkills();
   setFortState(NOT_DECIDED, 0);
   setJdbcState(JdbcEntityState.UPDATED);
   update();
 }