Ejemplo n.º 1
0
  public void showFlyText(
      String stfFile,
      String stfString,
      String customText,
      int xp,
      float scale,
      RGB color,
      int displayType) {
    Set<Client> observers = getObservers();

    if (getClient() != null) {
      getClient()
          .getSession()
          .write(
              (new ObjControllerMessage(
                      0x0000000B,
                      new ShowFlyText(
                          getObjectID(),
                          getObjectID(),
                          56,
                          1,
                          1,
                          -1,
                          stfFile,
                          stfString,
                          customText,
                          xp,
                          scale,
                          color,
                          displayType)))
                  .serialize());
    }

    for (Client client : observers) {
      client
          .getSession()
          .write(
              (new ObjControllerMessage(
                      0x0000000B,
                      new ShowFlyText(
                          client.getParent().getObjectID(),
                          getObjectID(),
                          56,
                          1,
                          1,
                          -1,
                          stfFile,
                          stfString,
                          customText,
                          xp,
                          scale,
                          color,
                          displayType)))
                  .serialize());
    }
  }
Ejemplo n.º 2
0
  public void cleanTradeSession(Client actorClient, Client targetTradeClient) {

    TradeCompleteMessage partnerCompleteTrade = new TradeCompleteMessage();
    targetTradeClient.getSession().write(partnerCompleteTrade.serialize());

    TradeCompleteMessage clientCompleteTrade = new TradeCompleteMessage();
    actorClient.getSession().write(clientCompleteTrade.serialize());

    actorClient.getSession().removeAttribute("tradeSession");
    actorClient.getSession().removeAttribute("tradeSessionIsVerified");
    targetTradeClient.getSession().removeAttribute("tradeSession");
    targetTradeClient.getSession().removeAttribute("tradeSessionIsVerified");
  }
Ejemplo n.º 3
0
  public void showFlyText(
      String stf,
      OutOfBand outOfBand,
      float scale,
      RGB color,
      int displayType,
      boolean notifyObservers) {
    if (outOfBand == null) {
      outOfBand = new OutOfBand();
    }

    if (color == null) {
      color = new RGB(255, 255, 255);
    }

    if (getClient() != null) {
      getClient()
          .getSession()
          .write(
              (new ObjControllerMessage(
                      0x0000000B,
                      new ShowFlyText(
                          getObjectID(), getObjectID(), stf, outOfBand, scale, color, displayType)))
                  .serialize());
    }

    if (notifyObservers) {
      Set<Client> observers = getObservers();

      for (Client client : observers) {
        client
            .getSession()
            .write(
                (new ObjControllerMessage(
                        0x0000000B,
                        new ShowFlyText(
                            client.getParent().getObjectID(),
                            getObjectID(),
                            stf,
                            outOfBand,
                            scale,
                            color,
                            displayType)))
                    .serialize());
      }
    }
  }
Ejemplo n.º 4
0
  @Override
  public void sendBaselines(Client destination) {

    if (destination == null || destination.getSession() == null) {
      System.out.println("NULL destination");
      return;
    }

    destination.getSession().write(messageBuilder.buildBaseline3());
    destination.getSession().write(messageBuilder.buildBaseline6());
    destination.getSession().write(messageBuilder.buildBaseline8());
    destination.getSession().write(messageBuilder.buildBaseline9());

    UpdatePVPStatusMessage upvpm = new UpdatePVPStatusMessage(getObjectID());
    upvpm.setFaction(UpdatePVPStatusMessage.factionCRC.Neutral);
    upvpm.setStatus(getPvPBitmask());
    destination.getSession().write(upvpm.serialize());
  }
  public boolean checkName(String name, Client client, boolean allowSpaces) {
    // TODO: check for dev names, profane names, iconic names etc
    try {
      if (checkForDuplicateName(name, client.getAccountId())
          || (!allowSpaces && !name.matches(allowedCharsRegex))
          || (allowSpaces && !name.matches(allowedCharsRegexWithSpace))) return false;
    } catch (SQLException e) {
      e.printStackTrace();
    }

    return true;
  }
Ejemplo n.º 6
0
  @Override
  public void sendBaselines(Client destination) {

    if (destination == null || destination.getSession() == null) {
      System.out.println("NULL session");
      return;
    }

    destination.getSession().write(messageBuilder.buildBaseline3());
    destination.getSession().write(messageBuilder.buildBaseline6());
    if (destination == getClient()) {
      destination.getSession().write(messageBuilder.buildBaseline1());
      destination.getSession().write(messageBuilder.buildBaseline4());
    }
    // destination.getSession().write(messageBuilder.buildBaseline8());
    // destination.getSession().write(messageBuilder.buildBaseline9());

    if (destination != getClient()) {
      UpdatePVPStatusMessage upvpm =
          new UpdatePVPStatusMessage(
              getObjectID(),
              NGECore.getInstance()
                  .factionService
                  .calculatePvpStatus((CreatureObject) destination.getParent(), this),
              getFaction());
      destination.getSession().write(upvpm.serialize());
      UpdatePostureMessage upm = new UpdatePostureMessage(getObjectID(), getPosture());
      destination.getSession().write(upm.serialize());
    }
  }
Ejemplo n.º 7
0
  public List<SWGObject> getSFPlayers() {
    List<SWGObject> flagged = new ArrayList<SWGObject>();

    synchronized (core.getActiveConnectionsMap()) {
      for (Client client : core.getActiveConnectionsMap().values()) {
        if (client.getParent() != null && client.getParent() instanceof CreatureObject) {
          flagged.add(client.getParent());
        }
      }
    }

    Iterator<SWGObject> it = flagged.iterator();

    while (it.hasNext()) {
      SWGObject obj = it.next();
      if (((CreatureObject) obj).getFactionStatus() != 2) {
        it.remove();
      }
    }

    return flagged;
  }
Ejemplo n.º 8
0
  public void updatePvpStatus() {
    HashSet<Client> observers = new HashSet<Client>(getObservers());

    for (Iterator<Client> it = observers.iterator(); it.hasNext(); ) {
      Client observer = it.next();

      if (observer.getParent() != null) {
        observer
            .getSession()
            .write(
                new UpdatePVPStatusMessage(
                        this.getObjectID(),
                        NGECore.getInstance()
                            .factionService
                            .calculatePvpStatus((CreatureObject) observer.getParent(), this),
                        getFaction())
                    .serialize());
        if (getClient() != null) {
          getClient()
              .getSession()
              .write(
                  new UpdatePVPStatusMessage(
                          observer.getParent().getObjectID(),
                          NGECore.getInstance()
                              .factionService
                              .calculatePvpStatus(
                                  (CreatureObject) this, (CreatureObject) observer.getParent()),
                          getFaction())
                      .serialize());
        }
      }
    }

    if (getClient() != null) {
      CreatureObject companion =
          NGECore.getInstance().mountService.getCompanion((CreatureObject) this);

      if (companion != null) {
        companion.updatePvpStatus();
      }
    }
  }
Ejemplo n.º 9
0
  public void sendBaselines(Client destination) {
    if (destination != null && destination.getSession() != null) {
      destination.getSession().write(getBaseline(3).getBaseline());
      destination.getSession().write(getBaseline(6).getBaseline());

      Client parent = ((getGrandparent() == null) ? null : getGrandparent().getClient());

      if (parent != null && destination == parent) {
        destination.getSession().write(getBaseline(8).getBaseline());
        destination.getSession().write(getBaseline(9).getBaseline());
      }

      if (destination.getParent() != this) {
        UpdatePVPStatusMessage upvpm = new UpdatePVPStatusMessage(getObjectID());
        upvpm.setFaction(CRC.StringtoCRC(getFaction()));
        upvpm.setStatus(
            NGECore.getInstance()
                .factionService
                .calculatePvpStatus((CreatureObject) destination.getParent(), this));
        destination.getSession().write(upvpm.serialize());
      }
    }
  }
Ejemplo n.º 10
0
 public long getTradeAttribute(Client client) {
   long tradeSessionValue;
   tradeSessionValue = (long) client.getSession().getAttribute("tradeSession");
   return tradeSessionValue;
 }