Example #1
0
 public void teleportObelisk(int port) {
   int random = Misc.random(5);
   while (random == port) {
     random = Misc.random(5);
   }
   for (int j = 0; j < Server.playerHandler.players.length; j++) {
     if (Server.playerHandler.players[j] != null) {
       Client c = (Client) Server.playerHandler.players[j];
       if (c.goodDistance(
           c.getX(), c.getY(), obeliskCoords[port][0] + 2, obeliskCoords[port][1] + 2, 1)) {
         c.getPA().startTeleport2(obeliskCoords[random][0] + 2, obeliskCoords[random][1] + 2, 0);
       }
     }
   }
 }
Example #2
0
 public boolean newPlayerClient(Client client1) {
   int slot = -1;
   for (int i = 1; i < Config.MAX_PLAYERS; i++) {
     if (players[i] == null || players[i].disconnected) {
       slot = i;
       break;
     }
   }
   if (slot == -1) return false;
   client1.handler = this;
   client1.playerId = slot;
   players[slot] = client1;
   players[slot].isActive = true;
   players[slot].connectedFrom =
       ((InetSocketAddress) client1.getSession().getRemoteAddress()).getAddress().getHostAddress();
   if (Config.SERVER_DEBUG)
     Misc.println(
         "Player Slot "
             + slot
             + " slot 0 "
             + players[0]
             + " Player Hit "
             + players[
                 slot]); // does nothing.... ;;players dont give the right amount of playesr? i am
   // getting the right amount why not me? logout log inand u wont get the
   // right
   return true;
 }
Example #3
0
  public static void ItemonObject(Client c, int objectID, int objectX, int objectY, int itemId) {
    if (!c.getItems().playerHasItem(itemId, 1)) return;
    switch (objectID) {
      case 15621:
        Server.getWarriorsGuild().handleArmor(c, itemId, objectX, objectY);
        break;
      case 2783:
        c.getSmithingInt().showSmithInterface(itemId);
        break;
      case 8151:
      case 8389:
        c.getFarming().checkItemOnObject(itemId);
        break;
      case 2644:
        c.getFlaxStringer().itemOnObject(itemId);
        break;

      case 409:
        if (c.getPrayer().IsABone(itemId)) c.getPrayer().bonesOnAltar(itemId);
        break;
      default:
        if (c.playerRights == 3)
          Misc.println("Player At Object id: " + objectID + " with Item id: " + itemId);
        break;
    }
  }
Example #4
0
 public static void ItemonObject(Client c, int objectID, int objectX, int objectY, int itemId) {
   if (!c.getItems().playerHasItem(itemId, 1)) return;
   switch (objectID) {
     case 2783:
       c.getSmithingInt().showSmithInterface(itemId);
       break;
     case 7965:
     case 8389:
       c.getFarming().checkItemOnObject(itemId);
       break;
     case 2728:
     case 12269:
       c.getCooking().itemOnObject(itemId);
       break;
     case 15621:
       if (c.absX == 2857 && c.absY == 3537 || c.absX == 2851 && c.absY == 3537) {
         c.getWarriorsGuild().handleArmor(c, itemId, objectX, objectY);
       }
       break;
     case 409:
       if (c.getPrayer().isBone(itemId)) c.getPrayer().bonesOnAltar(itemId);
       break;
     default:
       if (c.playerRights == 3)
         Misc.println("Player At Object id: " + objectID + " with Item id: " + itemId);
       break;
   }
 }
Example #5
0
 /** Update objects when entering a new region or logging in */
 public void updateObjects(Client c) {
   for (Objects o : globalObjects) {
     if (c != null) {
       if (c.heightLevel == o.getObjectHeight() && o.objectTicks == 0) {
         if (c.distanceToPoint(o.getObjectX(), o.getObjectY()) <= 60) {
           c.getPA()
               .object(
                   o.getObjectId(),
                   o.getObjectX(),
                   o.getObjectY(),
                   o.getObjectFace(),
                   o.getObjectType());
         }
       }
     }
   }
   if (10 + Misc.random(10) == 15 && !Flax.flaxRemoved.isEmpty()) {
     int[] flax =
         Flax.flaxRemoved.get(Flax.flaxRemoved.indexOf(Flax.flaxRemoved.iterator().next()));
     // Server.objectHandler.createAnObject(2646, flax[0], flax[1]);
     // c.getPA().checkObjectSpawn(2646, flax[0], flax[1]);
     Flax.flaxRemoved.remove(Flax.flaxRemoved.indexOf(flax));
   }
   if (c.distanceToPoint(2813, 3463) <= 60) {
     c.getFarming().updateHerbPatch();
   }
   if (c.distanceToPoint(2961, 3389) <= 60) {
     c.getPA().object(6552, 2961, 3389, -1, 10);
   }
 }
Example #6
0
 public static void ItemonNpc(Client c, int itemId, int npcId, int slot) {
   switch (itemId) {
     default:
       if (c.playerRights == 3)
         Misc.println(
             "Player used Item id: " + itemId + " with Npc id: " + npcId + " With Slot : " + slot);
       break;
   }
 }
 public int getTimer(int b, int c, int level) {
   double timer =
       (int) ((Rock_Settings[b][1] * 2) + 20 + Misc.random(20))
           - ((Pick_Settings[c][2] * (Pick_Settings[c][2] * 0.75)) + level);
   if (timer < 2.0) {
     return 2;
   } else {
     return (int) timer;
   }
 }
Example #8
0
 public void openPlayerShop(Client o) {
   if (o == null || o.properLogout) return;
   c.getItems().resetItems(3823);
   resetShop(o);
   c.myShopClient = o;
   c.myShopId = 7390;
   c.isShopping = true;
   c.getPA().sendFrame248(3824, 3822);
   c.getPA().sendFrame126(Misc.optimizeText(o.playerName) + "'s personal shop!", 3901);
 }
Example #9
0
  /**
   * Adds a player to the local player list of another player.
   *
   * @param out the packet to write to.
   * @param player the host player.
   * @param other the player being added.
   */
  public static void addPlayer(PacketBuffer.WriteBuffer out, Player player, Player other) {
    out.writeBits(11, other.getSlot()); // Server slot.
    out.writeBit(true); // Yes, an update is required.
    out.writeBit(true); // Discard walking queue(?)

    // Write the relative position.
    Position delta = Misc.delta(player.getPosition(), other.getPosition());
    out.writeBits(5, delta.getY());
    out.writeBits(5, delta.getX());
  }
 public boolean newPlayerClient(Client client1) {
   int slot = -1;
   for (int i = 1; i < Config.MAX_PLAYERS; i++) {
     if ((players[i] == null) || players[i].disconnected) {
       slot = i;
       break;
     }
   }
   if (slot == -1) return false;
   client1.handler = this;
   client1.playerId = slot;
   players[slot] = client1;
   players[slot].isActive = true;
   players[slot].connectedFrom =
       ((InetSocketAddress) client1.getSession().getRemoteAddress()).getAddress().getHostAddress();
   if (Config.SERVER_DEBUG)
     Misc.println(
         "Player Slot " + slot + " slot 0 " + players[0] + " Player Hit " + players[slot]);
   return true;
 }
Example #11
0
 private void plantSeed(int seedId, int herbId, int exp, int slot) {
   if (c.playerLevel[c.playerFarming] < FARMING_REQS[slot]) {
     c.sendMessage("You require a farming level of " + FARMING_REQS[slot] + " to farm this seed.");
   } else if (!seedPlanted
       && patchRaked
       && c.getItems().playerHasItem(seedId, 1)
       && c.getItems().playerHasItem(SEED_DIBBER, 1)) {
     c.getItems().deleteItem(seedId, c.getItems().getItemSlot(seedId), 1);
     c.getPA().addSkillXP(SEED_PLANT_EXP[slot] * Config.FARMING_EXPERIENCE, c.playerFarming);
     c.startAnimation(2291);
     c.getPA().refreshSkill(c.playerFarming);
     int herbAmount = Misc.random(5) + 3;
     c.farm[0] = herbId;
     c.farm[1] = herbAmount;
     c.sendMessage("You plant your seed. Water it and watch it grow.");
     seedPlanted = true;
   } else {
     c.sendMessage("You need to rake the patch or you've already planted a seed!");
   }
 }
Example #12
0
  public static void ItemonItem(Client c, int itemUsed, int useWith) {
    if (itemUsed == 227 || useWith == 227) c.getHerblore().handlePotMaking(itemUsed, useWith);
    if (c.getItems().getItemName(itemUsed).contains("(")
        && c.getItems().getItemName(useWith).contains("("))
      c.getPotMixing().mixPotion2(itemUsed, useWith);
    if (itemUsed == 1733 || useWith == 1733) c.getCrafting().handleLeather(itemUsed, useWith);
    if (itemUsed == 1755 || useWith == 1755) c.getCrafting().handleChisel(itemUsed, useWith);
    /*if (itemUsed == 946 || useWith == 946)
    	c.getFletching().handleLog(itemUsed,useWith);
    if (itemUsed == 53 || useWith == 53 || itemUsed == 52 || useWith == 52)
    	c.getFletching().makeArrows(itemUsed, useWith);*/
    if ((itemUsed == 1540 && useWith == 11286) || (itemUsed == 11286 && useWith == 1540)) {
      if (c.playerLevel[c.playerSmithing] >= 95) {
        c.getItems().deleteItem(1540, c.getItems().getItemSlot(1540), 1);
        c.getItems().deleteItem(11286, c.getItems().getItemSlot(11286), 1);
        c.getItems().addItem(11284, 1);
        c.sendMessage("You combine the two materials to create a dragonfire shield.");
        c.getPA().addSkillXP(500 * Config.SMITHING_EXPERIENCE, c.playerSmithing);
      } else {
        c.sendMessage("You need a smithing level of 95 to create a dragonfire shield.");
      }
    }
    if (itemUsed == 9142 && useWith == 9190 || itemUsed == 9190 && useWith == 9142) {
      if (c.playerLevel[c.playerFletching] >= 58) {
        int boltsMade =
            c.getItems().getItemAmount(itemUsed) > c.getItems().getItemAmount(useWith)
                ? c.getItems().getItemAmount(useWith)
                : c.getItems().getItemAmount(itemUsed);
        c.getItems().deleteItem(useWith, c.getItems().getItemSlot(useWith), boltsMade);
        c.getItems().deleteItem(itemUsed, c.getItems().getItemSlot(itemUsed), boltsMade);
        c.getItems().addItem(9241, boltsMade);
        c.getPA().addSkillXP(boltsMade * 6 * Config.FLETCHING_EXPERIENCE, c.playerFletching);
      } else {
        c.sendMessage("You need a fletching level of 58 to fletch this item.");
      }
    }
    if (itemUsed == 9143 && useWith == 9191 || itemUsed == 9191 && useWith == 9143) {
      if (c.playerLevel[c.playerFletching] >= 63) {
        int boltsMade =
            c.getItems().getItemAmount(itemUsed) > c.getItems().getItemAmount(useWith)
                ? c.getItems().getItemAmount(useWith)
                : c.getItems().getItemAmount(itemUsed);
        c.getItems().deleteItem(useWith, c.getItems().getItemSlot(useWith), boltsMade);
        c.getItems().deleteItem(itemUsed, c.getItems().getItemSlot(itemUsed), boltsMade);
        c.getItems().addItem(9242, boltsMade);
        c.getPA().addSkillXP(boltsMade * 7 * Config.FLETCHING_EXPERIENCE, c.playerFletching);
      } else {
        c.sendMessage("You need a fletching level of 63 to fletch this item.");
      }
    }
    if (itemUsed == 9143 && useWith == 9192 || itemUsed == 9192 && useWith == 9143) {
      if (c.playerLevel[c.playerFletching] >= 65) {
        int boltsMade =
            c.getItems().getItemAmount(itemUsed) > c.getItems().getItemAmount(useWith)
                ? c.getItems().getItemAmount(useWith)
                : c.getItems().getItemAmount(itemUsed);
        c.getItems().deleteItem(useWith, c.getItems().getItemSlot(useWith), boltsMade);
        c.getItems().deleteItem(itemUsed, c.getItems().getItemSlot(itemUsed), boltsMade);
        c.getItems().addItem(9243, boltsMade);
        c.getPA().addSkillXP(boltsMade * 7 * Config.FLETCHING_EXPERIENCE, c.playerFletching);
      } else {
        c.sendMessage("You need a fletching level of 65 to fletch this item.");
      }
    }
    if (itemUsed == 9144 && useWith == 9193 || itemUsed == 9193 && useWith == 9144) {
      if (c.playerLevel[c.playerFletching] >= 71) {
        int boltsMade =
            c.getItems().getItemAmount(itemUsed) > c.getItems().getItemAmount(useWith)
                ? c.getItems().getItemAmount(useWith)
                : c.getItems().getItemAmount(itemUsed);
        c.getItems().deleteItem(useWith, c.getItems().getItemSlot(useWith), boltsMade);
        c.getItems().deleteItem(itemUsed, c.getItems().getItemSlot(itemUsed), boltsMade);
        c.getItems().addItem(9244, boltsMade);
        c.getPA().addSkillXP(boltsMade * 10 * Config.FLETCHING_EXPERIENCE, c.playerFletching);
      } else {
        c.sendMessage("You need a fletching level of 71 to fletch this item.");
      }
    }
    if (itemUsed == 9144 && useWith == 9194 || itemUsed == 9194 && useWith == 9144) {
      if (c.playerLevel[c.playerFletching] >= 58) {
        int boltsMade =
            c.getItems().getItemAmount(itemUsed) > c.getItems().getItemAmount(useWith)
                ? c.getItems().getItemAmount(useWith)
                : c.getItems().getItemAmount(itemUsed);
        c.getItems().deleteItem(useWith, c.getItems().getItemSlot(useWith), boltsMade);
        c.getItems().deleteItem(itemUsed, c.getItems().getItemSlot(itemUsed), boltsMade);
        c.getItems().addItem(9245, boltsMade);
        c.getPA().addSkillXP(boltsMade * 13 * Config.FLETCHING_EXPERIENCE, c.playerFletching);
      } else {
        c.sendMessage("You need a fletching level of 58 to fletch this item.");
      }
    }
    if (itemUsed == 1601 && useWith == 1755 || itemUsed == 1755 && useWith == 1601) {
      if (c.playerLevel[c.playerFletching] >= 63) {
        c.getItems().deleteItem(1601, c.getItems().getItemSlot(1601), 1);
        c.getItems().addItem(9192, 15);
        c.getPA().addSkillXP(8 * Config.FLETCHING_EXPERIENCE, c.playerFletching);
      } else {
        c.sendMessage("You need a fletching level of 63 to fletch this item.");
      }
    }
    if (itemUsed == 1607 && useWith == 1755 || itemUsed == 1755 && useWith == 1607) {
      if (c.playerLevel[c.playerFletching] >= 65) {
        c.getItems().deleteItem(1607, c.getItems().getItemSlot(1607), 1);
        c.getItems().addItem(9189, 15);
        c.getPA().addSkillXP(8 * Config.FLETCHING_EXPERIENCE, c.playerFletching);
      } else {
        c.sendMessage("You need a fletching level of 65 to fletch this item.");
      }
    }
    if (itemUsed == 1605 && useWith == 1755 || itemUsed == 1755 && useWith == 1605) {
      if (c.playerLevel[c.playerFletching] >= 71) {
        c.getItems().deleteItem(1605, c.getItems().getItemSlot(1605), 1);
        c.getItems().addItem(9190, 15);
        c.getPA().addSkillXP(8 * Config.FLETCHING_EXPERIENCE, c.playerFletching);
      } else {
        c.sendMessage("You need a fletching level of 71 to fletch this item.");
      }
    }
    if (itemUsed == 1603 && useWith == 1755 || itemUsed == 1755 && useWith == 1603) {
      if (c.playerLevel[c.playerFletching] >= 73) {
        c.getItems().deleteItem(1603, c.getItems().getItemSlot(1603), 1);
        c.getItems().addItem(9191, 15);
        c.getPA().addSkillXP(8 * Config.FLETCHING_EXPERIENCE, c.playerFletching);
      } else {
        c.sendMessage("You need a fletching level of 73 to fletch this item.");
      }
    }
    if (itemUsed == 1615 && useWith == 1755 || itemUsed == 1755 && useWith == 1615) {
      if (c.playerLevel[c.playerFletching] >= 73) {
        c.getItems().deleteItem(1615, c.getItems().getItemSlot(1615), 1);
        c.getItems().addItem(9193, 15);
        c.getPA().addSkillXP(8 * Config.FLETCHING_EXPERIENCE, c.playerFletching);
      } else {
        c.sendMessage("You need a fletching level of 73 to fletch this item.");
      }
    }
    if (itemUsed >= 11710 && itemUsed <= 11714 && useWith >= 11710 && useWith <= 11714) {
      if (c.getItems().hasAllShards()) {
        c.getItems().makeBlade();
      }
    }
    if (itemUsed == 2368 && useWith == 2366 || itemUsed == 2366 && useWith == 2368) {
      c.getItems().deleteItem(2368, c.getItems().getItemSlot(2368), 1);
      c.getItems().deleteItem(2366, c.getItems().getItemSlot(2366), 1);
      c.getItems().addItem(1187, 1);
    }

    if (c.getItems().isHilt(itemUsed) || c.getItems().isHilt(useWith)) {
      int hilt = c.getItems().isHilt(itemUsed) ? itemUsed : useWith;
      int blade = c.getItems().isHilt(itemUsed) ? useWith : itemUsed;
      if (blade == 11690) {
        c.getItems().makeGodsword(hilt);
      }
    }

    switch (itemUsed) {
      case 1511:
      case 1521:
      case 1519:
      case 1517:
      case 1515:
      case 1513:
      case 590:
        // c.getFiremaking().checkLogType(itemUsed, useWith);
        // c.sendMessage("Firemaking is disabled.");
        break;

      default:
        if (c.playerRights == 3)
          Misc.println("Player used Item id: " + itemUsed + " with Item id: " + useWith);
        break;
    }
  }
Example #13
0
  /**
   * Appends the state of a player's appearance to a buffer.
   *
   * @param player the player.
   * @param out the buffer.
   */
  public static void appendAppearance(Player player, PacketBuffer.WriteBuffer out) {
    PacketBuffer.WriteBuffer block = PacketBuffer.newWriteBuffer(128);

    /** Gender. */
    block.writeByte(player.getGender()); // Gender

    /** Head icon. */
    block.writeByte(player.getHeadIcon());

    /** Skull icon. */
    block.writeByte(player.getSkullIcon());
    if (player.getNpcAppearanceId() == -1) {

      if (player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_HEAD) > 1) {
        block.writeShort(
            0x200 + player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_HEAD));
      } else {
        block.writeByte(0);
      }

      /** Cape. */
      if (player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_CAPE) > 1) {
        block.writeShort(
            0x200 + player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_CAPE));
      } else {
        block.writeByte(0);
      }

      /** Amulet. */
      if (player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_AMULET) > 1) {
        block.writeShort(
            0x200 + player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_AMULET));
      } else {
        block.writeByte(0);
      }

      /** Weapon. */
      if (player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_WEAPON) > 1) {
        block.writeShort(
            0x200 + player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_WEAPON));
      } else {
        block.writeByte(0);
      }

      /** Chest. */
      if (player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_CHEST) > 1) {
        block.writeShort(
            0x200 + player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_CHEST));
      } else {
        block.writeShort(0x100 + player.getAppearance()[Misc.APPEARANCE_SLOT_CHEST]);
      }

      /** Shield. */
      if (player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_SHIELD) > 1) {
        block.writeShort(
            0x200 + player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_SHIELD));
      } else {
        block.writeByte(0);
      }

      /** Arms. */
      if (player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_CHEST) > 1) {

        if (!Misc.getIsPlatebody()[
            player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_CHEST)]) {
          block.writeShort(0x100 + player.getAppearance()[Misc.APPEARANCE_SLOT_ARMS]);
        } else {
          block.writeByte(0);
        }
      } else {
        block.writeShort(0x100 + player.getAppearance()[Misc.APPEARANCE_SLOT_ARMS]);
      }

      /** Legs. */
      if (player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_LEGS) > 1) {
        block.writeShort(
            0x200 + player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_LEGS));
      } else {
        block.writeShort(0x100 + player.getAppearance()[Misc.APPEARANCE_SLOT_LEGS]);
      }

      /** Head. */
      if (player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_HEAD) > 1
          && Misc.getIsFullHelm()[
              player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_HEAD)]) {
        block.writeByte(0);
      } else {
        block.writeShort(0x100 + player.getAppearance()[Misc.APPEARANCE_SLOT_HEAD]);
      }

      /** Hands. */
      if (player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_HANDS) > 1) {
        block.writeShort(
            0x200 + player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_HANDS));
      } else {
        block.writeShort(0x100 + player.getAppearance()[Misc.APPEARANCE_SLOT_HANDS]);
      }

      /** Feet. */
      if (player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_FEET) > 1) {
        block.writeShort(
            0x200 + player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_FEET));
      } else {
        block.writeShort(0x100 + player.getAppearance()[Misc.APPEARANCE_SLOT_FEET]);
      }

      /** Beard. */
      if (player.getGender() == Misc.GENDER_MALE) {
        if (player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_HEAD) > 1
                && !Misc.getIsFullHelm()[
                    player.getEquipment().getContainer().getItemId(Misc.EQUIPMENT_SLOT_HEAD)]
            || player.getEquipment().getContainer().isSlotFree(Misc.EQUIPMENT_SLOT_HEAD)) {
          block.writeShort(0x100 + player.getAppearance()[Misc.APPEARANCE_SLOT_BEARD]);
        } else {
          block.writeByte(0);
        }
      }

    } else {
      block.writeShort(-1);
      block.writeShort(player.getNpcAppearanceId());
    }

    /** Player colors */
    block.writeByte(player.getColors()[0]);
    block.writeByte(player.getColors()[1]);
    block.writeByte(player.getColors()[2]);
    block.writeByte(player.getColors()[3]);
    block.writeByte(player.getColors()[4]);

    /** Movement animations */
    block.writeShort(
        player.getUpdateAnimation().getStandingAnimation() == -1
            ? PlayerAnimation.getStandEmote()
            : player.getUpdateAnimation().getStandingAnimation()); // stand
    block.writeShort(PlayerAnimation.getStandTurnEmote()); // stand turn
    block.writeShort(
        player.getUpdateAnimation().getWalkingAnimation() == -1
            ? PlayerAnimation.getWalkEmote()
            : player.getUpdateAnimation().getWalkingAnimation()); // walk
    block.writeShort(PlayerAnimation.getTurn180Emote()); // turn 180
    block.writeShort(PlayerAnimation.getTurn90CWEmote()); // turn 90 cw
    block.writeShort(PlayerAnimation.getTurn90CCWEmote()); // turn 90 ccw
    block.writeShort(
        player.getUpdateAnimation().getRunningAnimation() == -1
            ? PlayerAnimation.getRunEmote()
            : player.getUpdateAnimation().getRunningAnimation()); // run

    /** Player context menus */
    block.writeLong(Misc.nameToLong(player.getUsername()));
    block.writeByte(player.getCombatLevel());
    block.writeShort(0);

    /** Append the block length and the block to the packet. */
    out.writeByte(block.getBuffer().position(), PacketBuffer.ValueType.C);
    out.writeBytes(block.getBuffer());
  }
Example #14
0
 public boolean loadDoorConfig(String fileName) {
   String line = "";
   String token = "";
   String token2 = "";
   String token2_2 = "";
   String[] token3 = new String[10];
   boolean EndOfFile = false;
   int ReadMode = 0;
   BufferedReader objectFile = null;
   try {
     objectFile = new BufferedReader(new FileReader("./" + fileName));
   } catch (FileNotFoundException fileex) {
     Misc.println(fileName + ": file not found.");
     return false;
   }
   try {
     line = objectFile.readLine();
   } catch (IOException ioexception) {
     Misc.println(fileName + ": error loading file.");
     return false;
   }
   int door = 0;
   while (EndOfFile == false && line != null) {
     line = line.trim();
     int spot = line.indexOf("=");
     if (spot > -1) {
       token = line.substring(0, spot);
       token = token.trim();
       token2 = line.substring(spot + 1);
       token2 = token2.trim();
       token2_2 = token2.replaceAll("\t\t", "\t");
       token2_2 = token2_2.replaceAll("\t\t", "\t");
       token2_2 = token2_2.replaceAll("\t\t", "\t");
       token2_2 = token2_2.replaceAll("\t\t", "\t");
       token2_2 = token2_2.replaceAll("\t\t", "\t");
       token3 = token2_2.split("\t");
       if (token.equals("door")) {
         doors[door][0] = Integer.parseInt(token3[0]);
         doors[door][1] = Integer.parseInt(token3[1]);
         doors[door][2] = Integer.parseInt(token3[2]);
         doors[door][3] = Integer.parseInt(token3[3]);
         doors[door][4] = Integer.parseInt(token3[4]);
         door++;
       }
     } else {
       if (line.equals("[ENDOFDOORLIST]")) {
         try {
           objectFile.close();
         } catch (IOException ioexception) {
         }
         return true;
       }
     }
     try {
       line = objectFile.readLine();
     } catch (IOException ioexception1) {
       EndOfFile = true;
     }
   }
   try {
     objectFile.close();
   } catch (IOException ioexception) {
   }
   return false;
 }