Пример #1
0
  public void addMember(L2PcInstance player) {
    if (getMembers().contains(player)) return;

    PartyRoomManager.getInstance().removeFromWaitingList(player);
    broadcastPacket(new ExManagePartyRoomMember(ExManagePartyRoomMember.ADDED, player));
    broadcastPacket(new SystemMessage(SystemMessageId.S1_ENTERED_PARTY_ROOM).addPcName(player));
    updateRoomStatus(false);
    getMembers().add(player);
    player.setPartyRoom(this);
    player.sendPacket(new PartyMatchDetail(this));
    player.sendPacket(new ExPartyRoomMember(this, getMemberCount() == 1));
  }
Пример #2
0
  public void removeMember(L2PcInstance member, boolean oust) {
    // the last member (leader) cannot be removed
    if (getMemberCount() == 1 || !getMembers().remove(member)) return;

    member.setPartyRoom(null);
    member.sendPacket(ExClosePartyRoom.STATIC_PACKET);
    if (oust) member.sendPacket(SystemMessageId.OUSTED_FROM_PARTY_ROOM);
    else member.sendPacket(SystemMessageId.PARTY_ROOM_EXITED);

    SystemMessage sm;
    if (oust) sm = new SystemMessage(SystemMessageId.S1_KICKED_FROM_PARTY_ROOM);
    else sm = new SystemMessage(SystemMessageId.S1_LEFT_PARTY_ROOM);
    sm.addPcName(member);
    broadcastPacket(new ExManagePartyRoomMember(ExManagePartyRoomMember.REMOVED, member));
    broadcastPacket(sm);
    updateRoomStatus(false);
  }
Пример #3
0
  private void updateOwnerInDB() {
    L2Clan clan = getOwnerClan();
    int clanId = 0;

    if (clan != null) {
      clanId = clan.getClanId();
      _lastOwnedTime = System.currentTimeMillis();
    } else _lastOwnedTime = 0;

    Connection con = null;
    try {
      con = L2DatabaseFactory.getInstance().getConnection(con);
      PreparedStatement statement;

      statement =
          con.prepareStatement(
              "UPDATE fort SET owner=?, lastOwnedTime=?, state=?, castleId=? WHERE id = ?");
      statement.setInt(1, clanId);
      statement.setLong(2, _lastOwnedTime);
      statement.setInt(3, 0);
      statement.setInt(4, 0);
      statement.setInt(5, getFortId());
      statement.execute();
      statement.close();

      // ============================================================================
      // Announce to clan memebers
      if (clan != null) {
        clan.setHasFort(getFortId()); // Set has fort flag for new owner
        SystemMessage sm;
        sm = new SystemMessage(SystemMessageId.S1);
        sm.addString(clan.getName() + " победил в битве за форт " + getName());
        Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
        for (L2PcInstance player : pls) player.sendPacket(sm);

        clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
        clan.broadcastToOnlineMembers(new PlaySound(1, "Siege_Victory", 0, 0, 0, 0, 0));
        ThreadPoolManager.getInstance()
            .scheduleGeneral(
                new FortUpdater(clan, 1), 3600000); // Schedule owner tasks to start running
      }
    } catch (Exception e) {
      _log.warn("Exception: updateOwnerInDB(L2Clan clan): " + e.getMessage());
      e.printStackTrace();
    } finally {
      try {
        con.close();
      } catch (Exception e) {
        _log.warn("" + e.getMessage());
        e.printStackTrace();
      }
    }
  }
Пример #4
0
  private void adminAtmosphere(String type, String state, L2PcInstance admin) {
    L2GameServerPacket packet = null;

    if (type.equals("signsky")) {
      if (state.equals("dawn")) packet = new SSQInfo(2);
      else if (state.equals("dusk")) packet = new SSQInfo(1);
    } else if (type.equals("sky")) {
      if (state.equals("night")) packet = SunSet.STATIC_PACKET;
      else if (state.equals("day")) packet = SunRise.STATIC_PACKET;
      else if (state.equals("red")) packet = new ExRedSky(10);
    } else admin.sendMessage("Используйте: //atmosphere <signsky dawn|dusk>|<sky day|night|red>");
    if (packet != null)
      for (L2PcInstance player : L2World.getInstance().getAllPlayers()) player.sendPacket(packet);
  }
Пример #5
0
  private void performSocial(int action, L2Object target, L2PcInstance admin) {
    if (target == null) return;

    try {
      if (target instanceof L2Character) {
        if (target instanceof L2ChestInstance) {
          admin.sendPacket(SystemMessageId.NOTHING_HAPPENED);
          return;
        }
        if ((target instanceof L2NpcInstance) && (action < 1 || action > 6)) {
          admin.sendPacket(SystemMessageId.NOTHING_HAPPENED);
          return;
        }
        if ((target.isPlayer()) && (action < 2 || action > 16)) {
          admin.sendPacket(SystemMessageId.NOTHING_HAPPENED);
          return;
        }
        L2Character character = (L2Character) target;
        character.broadcastPacket(new SocialAction(target.getObjectId(), action));
      } else return;
    } catch (Exception e) {
    }
    return;
  }
Пример #6
0
  /**
   * Verifies if player can join the given party room and either adds the player to the party room
   * or sends a message why the player could not join the room.<br>
   * <I>Parameters may be <CODE>null</CODE>, which guarantees <CODE>false</CODE></I>
   *
   * @param activeChar a player
   * @param room a party room
   * @param checkForParty whether check if the player is in party/[room]
   * @return true if player joined the given room, false otherwise
   */
  public static final boolean tryJoin(
      L2PcInstance activeChar, L2PartyRoom room, boolean checkForParty) {
    if (activeChar == null) return false;

    if (checkForParty) {
      if (activeChar.getPartyRoom() != null || activeChar.getParty() != null) {
        activeChar.sendPacket(SystemMessageId.PARTY_ROOM_FORBIDDEN);
        return false;
      }
    }

    if (room == null) {
      activeChar.sendPacket(SystemMessageId.PARTY_ROOM_FORBIDDEN);
      return false;
    } else if (!room.checkLevel(activeChar.getLevel())) {
      activeChar.sendPacket(SystemMessageId.CANT_ENTER_PARTY_ROOM);
      return false;
    } else if (room.getMemberCount() >= room.getMaxMembers()) {
      activeChar.sendPacket(SystemMessageId.PARTY_ROOM_FULL);
      return false;
    }
    room.addMember(activeChar);
    return true;
  }
Пример #7
0
  @Override
  public void runCommand(L2PcInstance admin, String... params) {
    if (admin == null) return;

    final String command = params[0];

    if (command.equals("vis") || command.equals("visible")) {
      admin.getAppearance().setVisible();
      admin.broadcastUserInfo(true);
      return;
    } else if (command.equals("invis") || command.equals("invisible")) {
      admin.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
      admin.setTarget(admin);
      admin.disableAllSkills();
      admin.getAppearance().setInvisible();
      admin.updateInvisibilityStatus();
      admin.enableAllSkills();
      return;
    } else if (command.equals("earthquake")) {
      try {
        int intensity = Integer.parseInt(params[1]);
        int duration = Integer.parseInt(params[2]);
        Earthquake eq =
            new Earthquake(admin.getX(), admin.getY(), admin.getZ(), intensity, duration);
        admin.broadcastPacket(eq);
      } catch (Exception e) {
        admin.sendMessage("Используйте: //earthquake <intensity> <duration>");
      }
      sendHtml(admin, "effects");
      return;
    } else if (command.equals("atmosphere")) {
      try {
        String type = params[1];
        String state = params[2];
        adminAtmosphere(type, state, admin);
      } catch (Exception ex) {
      }
      sendHtml(admin, "effects");
      return;
    } else if (command.equals("sounds")) {
      methods.showHelpPage(admin, "songs/songs.htm");
      return;
    } else if (command.equals("play_sounds")) {
      try {
        String cmd = "";
        for (int x = 1; x < params.length; x++) cmd += (" " + params[x]);
        methods.showHelpPage(admin, "songs/songs" + cmd + ".htm");
      } catch (StringIndexOutOfBoundsException e) {
      }
      return;
    } else if (command.startsWith("play_sound")) {
      try {
        String cmd = "";
        for (int x = 1; x < params.length; x++) cmd += (" " + params[x]);
        playAdminSound(admin, cmd);
      } catch (StringIndexOutOfBoundsException e) {
      }
      return;
    } else if (command.equals("para")) {
      String type = "1";
      if (params.length > 1) type = params[1];
      try {
        L2Object target = admin.getTarget();
        L2Character player = null;
        if (target instanceof L2Character) {
          player = (L2Character) target;
          if (type.equals("1")) player.startAbnormalEffect(AbnormalEffect.HOLD_1);
          else player.startAbnormalEffect(AbnormalEffect.HOLD_2);
          player.setIsParalyzed(true);
          StopMove sm = new StopMove(player);
          player.sendPacket(sm);
          player.broadcastPacket(sm);
        }
      } catch (Exception e) {
      }
    } else if (command.equals("unpara")) {
      try {
        L2Object target = admin.getTarget();
        L2Character player = null;
        if (target instanceof L2Character) {
          player = (L2Character) target;
          player.stopAbnormalEffect(AbnormalEffect.HOLD_1);
          player.stopAbnormalEffect(AbnormalEffect.HOLD_2);
          player.setIsParalyzed(false);
        }
      } catch (Exception e) {
      }
    } else if (command.equals("para_all") || command.equals("unpara_all")) {
      boolean para = command.equals("para_all");
      try {
        for (L2PcInstance player : admin.getKnownList().getKnownPlayers().values()) {
          if (!player.isGM()) {
            if (para) {
              player.startAbnormalEffect(AbnormalEffect.HOLD_1);
              player.setIsParalyzed(true);
              player.broadcastPacket(new StopMove(player));
            } else {
              player.stopAbnormalEffect(AbnormalEffect.HOLD_1);
              player.setIsParalyzed(false);
            }
          }
        }
      } catch (Exception e) {
      }
      sendHtml(admin, "effects");
      return;
    } else if (command.equals("bighead") || command.equals("shrinkhead")) {
      try {
        L2Object target = admin.getTarget();
        if (target == null) target = admin;
        if (target != null && target instanceof L2Character) {
          if (command.equals("shrinkhead"))
            ((L2Character) target).stopAbnormalEffect(AbnormalEffect.BIG_HEAD);
          else ((L2Character) target).startAbnormalEffect(AbnormalEffect.BIG_HEAD);
        }
      } catch (Exception e) {
      }
      sendHtml(admin, "effects");
      return;
    } else if (command.equals("gmspeed")) {
      try {
        int val = Integer.parseInt(params[1]);
        admin.stopSkillEffects(7029);
        if (val == 0 && admin.getFirstEffect(7029) != null)
          admin.sendPacket(
              new SystemMessage(SystemMessageId.EFFECT_S1_DISAPPEARED).addSkillName(7029));
        else if ((val >= 1) && (val <= 4)) {
          L2Skill gmSpeedSkill = SkillTable.getInstance().getInfo(7029, val);
          admin.doSimultaneousCast(gmSpeedSkill);
        }
      } catch (Exception e) {
        admin.sendMessage("Используйте: //gmspeed [0-4]");
      } finally {
        admin.updateEffectIcons();
      }
      return;
    } else if (command.equals("social") || command.equals("social_menu")) {
      if (command.equals("social_menu")) {
        sendHtml(admin, "submenus/social_menu");
        return;
      }

      try {
        if (params.length == 3) {
          int social = Integer.parseInt(params[1]);
          int radius = Integer.parseInt(params[2]);

          for (L2PcInstance pl : admin.getKnownList().getKnownPlayersInRadius(radius)) {
            if (pl == null
                || pl.isAlikeDead()
                || pl.isOfflineTrade()
                || pl.isTeleporting()
                || pl.inPrivateMode()) continue;
            performSocial(social, pl, admin);
          }
          admin.sendMessage("Социальное дествие отправлено всем в радиусе " + radius);
        } else if (params.length == 2) {
          int social = Integer.parseInt(params[1]);
          L2Object obj = admin.getTarget();
          if (obj == null) obj = admin;

          performSocial(social, obj, admin);
        }
      } catch (Exception e) {
        admin.sendMessage("Используйте: //social [id]");
      }
      sendHtml(admin, "submenus/social_menu");
      return;
    } else if (command.equals("abnormal") || command.equals("abnormal_menu")) {
      if (command.equals("abnormal_menu")) {
        sendHtml(admin, "submenus/abnormal_menu");
        return;
      }

      try {
        if (params.length == 3) {
          int abnormal = Integer.decode("0x" + params[1]);
          int radius = Integer.parseInt(params[2]);

          for (L2PcInstance pl : admin.getKnownList().getKnownPlayersInRadius(radius)) {
            if (pl == null
                || pl.isAlikeDead()
                || pl.isOfflineTrade()
                || pl.isTeleporting()
                || pl.inPrivateMode()) continue;
            performAbnormal(abnormal, pl);
          }
          admin.sendMessage("Эффект отправлен всем в радиусе " + radius);
        } else if (params.length == 2) {
          int abnormal = Integer.decode("0x" + params[1]);
          L2Object obj = admin.getTarget();
          if (obj == null) obj = admin;

          performAbnormal(abnormal, obj);
        }
      } catch (Exception e) {
        admin.sendMessage("Используйте: //social [id]");
      }
      sendHtml(admin, "submenus/abnormal_menu");
      return;
    }
  }
Пример #8
0
 private void sendHtml(L2PcInstance admin, String patch) {
   String name = (patch + ".htm");
   NpcHtmlMessage html = new NpcHtmlMessage(admin.getObjectId());
   html.setFile("data/html/admin/menus/" + name);
   admin.sendPacket(html);
 }
Пример #9
0
 private void playAdminSound(L2PcInstance admin, String sound) {
   PlaySound _snd = new PlaySound(1, sound);
   admin.sendPacket(_snd);
   admin.broadcastPacket(_snd);
   admin.sendMessage("Playing " + sound + ".");
 }
Пример #10
0
 public void broadcastPacket(L2GameServerPacket toLeader, L2GameServerPacket toMember) {
   L2PcInstance leader = getLeader();
   for (L2PcInstance player : getMembers())
     if (player == leader) player.sendPacket(toLeader);
     else player.sendPacket(toMember);
 }
Пример #11
0
 public void broadcastPacket(L2GameServerPacket packet) {
   for (L2PcInstance player : getMembers()) player.sendPacket(packet);
 }