Package be.demmel.jgws.entities

Examples of be.demmel.jgws.entities.Account


  }

  // just a placeholder that tests the configuration
  @Test
  public void placeHolderTest() {
    Account account = new Account(123, 1234, false, new byte[]{}, "root@gwca.be", "pass", 12, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344);
    // persist the user
    account = persist(account);

    // retrieve the user using his ID
    Account retrievedUser = retrieveById(Account.class, account.getId());

    Assert.assertEquals("root@gwca.be", retrievedUser.getEmail());
  }
View Full Code Here


    // the real handle starts here

    // String selectSql = "select * from accounts_masterdata where email=\"" + packet.getEmail() /* + "\" and password=\"" + password */+
    // "\"";
    Account account = this.getAccountByEmailAddress(packet.getEmail());

    int errorCode = 0;
    if (account == null) {
      errorCode = 227;
    } else if (account.isBanned()) {
      errorCode = 45;
    }

    if (errorCode != 0) {
      P003_StreamTerminator streamTerminator = new P003_StreamTerminator();
      streamTerminator.setErrorCode(errorCode);
      streamTerminator.setLoginCount(serverData.getLoginCount());

      ctx.write(streamTerminator);
      return;
    }

    int accountId = account.getAccountId();
    int charId = account.getCharId();

    // set the chosen character for the account, as it's important for the next step!!
    serverData.setCharId(charId);
    serverData.setAccId(accountId);

    serverData.setStatus(ClientStatus.AT_CHAR_VIEW);

    Set<Character> characters = this.getCharactersByAccountId(accountId);

    // process all characters
    for (Character character : characters) {
      // load each character
      int mapId = character.getMapId();
      if (character.getCharId() == serverData.getCharId()) {
        serverData.setMapId(mapId);
      }

      // send a packet to the client containing the info
      P007_CharacterInfo characterInfo = new P007_CharacterInfo();
      characterInfo.setLoginCount(serverData.getLoginCount());
      characterInfo.setStaticHash(new short[16]);
      characterInfo.setStaticData(0);
      characterInfo.setCharacterName(character.getCharName());

      // create the appearance byte array
      short remainderLength = 0;

      byte[] armorHead = character.getArmorHead();
      byte[] armorChest = character.getArmorChest();
      byte[] armorArms = character.getArmorArms();
      byte[] armorLegs = character.getArmorLegs();
      byte[] armorFeet = character.getArmorFeet();

      if (armorHead != null && armorHead.length != 0) {
        remainderLength++;
      }

      if (armorChest != null && armorChest.length != 0) {
        remainderLength++;
      }

      if (armorArms != null && armorArms.length != 0) {
        remainderLength++;
      }

      if (armorLegs != null && armorLegs.length != 0) {
        remainderLength++;
      }

      if (armorFeet != null && armorFeet.length != 0) {
        remainderLength++;
      }

      // appearance!
      ByteBuf buffer = Unpooled.buffer(512);
      buffer = buffer.order(ByteOrder.LITTLE_ENDIAN);
      buffer.writeShort(6);
      buffer.writeShort(mapId);
      RawConverter.writeUnsignedByteArray(new short[] { 0x33, 0x36, 0x31, 0x30 }, buffer);
      buffer.writeByte((character.getLookHeight() << 4) | character.getLookSex());
      buffer.writeByte((character.getLookHairColor() << 4) | character.getLookSkinColor());
      buffer.writeByte((character.getProfessionprimary() << 4) | character.getLookHairStyle());
      buffer.writeByte((character.getLookCampaign() << 4) | character.getLookFace());
      RawConverter.writeUnsignedByteArray(new short[16], buffer);
      buffer.writeByte((character.getLevel() << 4) | character.getLookCampaign());

      // RawConverter.writeUnsignedByte((short) ((resultChars.getInt("lookCampaign") << 4) | resultChars.getInt("lookFace")), buffer);

      buffer.writeByte(128 | (character.isShowHelm() ? 64 : 0) | (character.getProfessionSecondary() << 2)
          | (character.isPVP() ? 2 : 0) | (character.getLevel() > 15 ? 1 : 0));

      RawConverter.writeUnsignedByteArray(new short[] { 0xDD, 0xDD }, buffer);
      buffer.writeByte(remainderLength);
      RawConverter.writeUnsignedByteArray(new short[] { 0xDD, 0xDD, 0xDD, 0xDD }, buffer);

      if (armorHead != null && armorHead.length != 0) {
        this.writeBlobField(armorHead, buffer);
      }

      if (armorChest != null && armorChest.length != 0) {
        this.writeBlobField(armorChest, buffer);
      }

      if (armorArms != null && armorArms.length != 0) {
        this.writeBlobField(armorArms, buffer);
      }

      if (armorLegs != null && armorLegs.length != 0) {
        this.writeBlobField(armorLegs, buffer);
      }

      if (armorFeet != null && armorFeet.length != 0) {
        this.writeBlobField(armorFeet, buffer);
      }

      // convert to short.... again
      short[] convertedData = new short[buffer.writerIndex() + 1];

      StringBuilder sb = new StringBuilder("Appearance: ");
      for (int i = 0; i < buffer.writerIndex(); i++) {
        convertedData[i] = (short) (buffer.readByte() & 0xFF);
        sb.append(convertedData[i]).append(" ");
      }
      characterInfo.setAppearance(convertedData);

      ctx.write(characterInfo);
    }

    // process an account data packet
    P022_AccountGuiInfo accountGuiSettings = new P022_AccountGuiInfo();
    accountGuiSettings.setLoginCount(serverData.getLoginCount());

    byte[] rawData = account.getGuiSettings();
    short[] convertedData = new short[rawData.length];

    for (int i = 0; i < rawData.length; i++) {
      convertedData[i] = (short) (rawData[i] & 0xFF);
    }
View Full Code Here

    if (!map.isIsPve() && playerData.getTeamNumber() < map.getPossibleSpawns().size()) {
      chosenSpwwnPoint = map.getPossibleSpawns().get(playerData.getTeamNumber());
    }

    Account account = this.getAccountByAccountId(playerData.getAccId());

    if (account == null) {
      return null;
    }

    int groupId = account.getGroupId();

    Group group = this.getGroupByGroupId(groupId);
    if (group == null) {
      return null;
    }
View Full Code Here

public class InitTestDataTest {
  @Test
  public void inject() {
    EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("jgws");
   
    Account account = new Account(1, 1, false, new byte[]{}, "root@root", "root", 6, 0, 0, 0, 0, 0, 0, 0, 0);
    persist(entityManagerFactory, account);
   
    Character character = new Character(1, "iDemmel", 1, 123, 22, (byte)5, (byte)2, false, 1337, 1337, 0, 0, 0, 0, null, null, 0, 1, 0, 4, 9, 1, 4, false, null, null, null, null, null, null, null);
    persist(entityManagerFactory, character);
   
View Full Code Here

TOP

Related Classes of be.demmel.jgws.entities.Account

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.