Package org.moparscape.msc.gs.model

Examples of org.moparscape.msc.gs.model.MenuHandler


   */
  public static final World world = Instance.getWorld();

  public void handlePacket(Packet p, IoSession session) throws Exception {
    Player player = (Player) session.getAttachment();
    MenuHandler menuHandler = player.getMenuHandler();
    if (menuHandler == null) {
      player.setSuspiciousPlayer(true);
      return;
    }
    int option = (int) p.readByte();
    String reply = menuHandler.getOption(option);
    player.resetMenuHandler();
    if (reply == null) {
      player.setSuspiciousPlayer(true);
      return;
    }
    menuHandler.handleReply(option, reply);
  }
View Full Code Here


                            .sendMessage(
                                "What would you like to make?");
                        String[] options = new String[] {
                            "Ring", "Necklace",
                            "Amulet" };
                        owner.setMenuHandler(new MenuHandler(
                            options) {
                          public void handleReply(
                              int option,
                              String reply) {
                            if (owner.isBusy()
                                || option < 0
                                || option > 2) {
                              return;
                            }
                            final int[] moulds = {
                                293, 295, 294 };
                            final int[] gems = {
                                -1, 164, 163,
                                162, 161, 523 };
                            String[] options = {
                                "Gold",
                                "Sapphire",
                                "Emerald",
                                "Ruby",
                                "Diamond",
                                "Dragonstone" };
                            final int craftType = option;
                            if (owner
                                .getInventory()
                                .countId(
                                    moulds[craftType]) < 1) {
                              owner.getActionSender()
                                  .sendMessage(
                                      "You need a "
                                          + EntityHandler
                                              .getItemDef(
                                                  moulds[craftType])
                                              .getName()
                                          + " to make a "
                                          + reply);
                              return;
                            }
                            owner.getActionSender()
                                .sendMessage(
                                    "What type of "
                                        + reply
                                        + " would you like to make?");
                            owner.setMenuHandler(new MenuHandler(
                                options) {
                              public void handleReply(
                                  int option,
                                  String reply) {
                                if (owner
                                    .isBusy()
                                    || option < 0
                                    || option > 5) {
                                  return;
                                }
                                if (option != 0
                                    && owner.getInventory()
                                        .countId(
                                            gems[option]) < 1) {
                                  owner.getActionSender()
                                      .sendMessage(
                                          "You don't have a "
                                              + reply
                                              + ".");
                                  return;
                                }
                                ItemCraftingDef def = EntityHandler
                                    .getCraftingDef((option * 3)
                                        + craftType);
                                if (def == null) {
                                  owner.getActionSender()
                                      .sendMessage(
                                          "Nothing interesting happens.");
                                  return;
                                }
                                if (owner
                                    .getCurStat(12) < def
                                    .getReqLevel()) {
                                  owner.getActionSender()
                                      .sendMessage(
                                          "You need at crafting level of "
                                              + def.getReqLevel()
                                              + " to make this");
                                  return;
                                }
                                if (owner
                                    .getInventory()
                                    .remove(item.id,
                                        item.amount,
                                        false)
                                    && (option == 0 || owner
                                        .getInventory()
                                        .remove(gems[option],
                                            1,
                                            false))) {
                                  showBubble();
                                  InvItem result = new InvItem(
                                      def.getItemID(),
                                      1);
                                  owner.getActionSender()
                                      .sendMessage(
                                          "You make a "
                                              + result.getDef()
                                                  .getName());
                                  owner.getInventory()
                                      .add(result.id,
                                          result.amount,
                                          false);
                                  owner.incExp(
                                      12,
                                      def.getExp(),
                                      true,
                                      true);
                                  owner.getActionSender()
                                      .sendStat(
                                          12);
                                  owner.getActionSender()
                                      .sendInventory();
                                }
                              }
                            });
                            owner.getActionSender()
                                .sendMenu(
                                    options);
                          }
                        });
                        owner.getActionSender()
                            .sendMenu(options);
                      }
                    });
              }
              if (item.id == 384) { // Silver Bar (Crafting)
                world.getDelayedEventHandler().add(
                    new MiniEvent(owner) {
                      public void action() {
                        owner.getActionSender()
                            .sendMessage(
                                "What would you like to make?");
                        String[] options = new String[] {
                            "Holy Symbol of Saradomin",
                            "UnHoly Symbol of Zamorak" };
                        owner.setMenuHandler(new MenuHandler(
                            options) {
                          public void handleReply(
                              int option,
                              String reply) {
                            if (owner.isBusy()
                                || option < 0
                                || option > 1) {
                              return;
                            }
                            int[] moulds = { 386,
                                1026 };
                            int[] results = { 44,
                                1027 };
                            if (owner
                                .getInventory()
                                .countId(
                                    moulds[option]) < 1) {
                              owner.getActionSender()
                                  .sendMessage(
                                      "You need a "
                                          + EntityHandler
                                              .getItemDef(
                                                  moulds[option])
                                              .getName()
                                          + " to make a "
                                          + reply);
                              return;
                            }
                            if (owner
                                .getCurStat(12) < 16) {
                              owner.getActionSender()
                                  .sendMessage(
                                      "You need a crafting level of 16 to make this");
                              return;
                            }
                            if (owner
                                .getInventory()
                                .remove(item.id,
                                    item.amount,
                                    false)) {
                              showBubble();
                              InvItem result = new InvItem(
                                  results[option]);
                              owner.getActionSender()
                                  .sendMessage(
                                      "You make a "
                                          + result.getDef()
                                              .getName());
                              owner.getInventory()
                                  .add(result.id,
                                      result.amount,
                                      false);
                              owner.incExp(12,
                                  50, true,
                                  true);
                              owner.getActionSender()
                                  .sendStat(
                                      12);
                              owner.getActionSender()
                                  .sendInventory();
                            }
                          }
                        });
                        owner.getActionSender()
                            .sendMenu(options);
                      }
                    });
              } else if (item.id == 625) { // Sand (Glass)
                if (!Server.isMembers()) {
                  owner.getActionSender().sendMessage(
                      GameServer.P2P_LIMIT_MESSAGE);
                  return;
                }
                if (player.getInventory().countId(624) < 1) {
                  owner.getActionSender()
                      .sendMessage(
                          "You need some soda ash to mix the sand with.");
                  return;
                }
                owner.setBusy(true);
                showBubble();
                owner.getActionSender()
                    .sendMessage(
                        "You put the seaweed and the soda ash in the furnace.");
                Instance.getDelayedEventHandler().add(
                    new ShortEvent(owner) {
                      public void action() {
                        if (player.getInventory()
                            .remove(624, 1, false)
                            && player
                                .getInventory()
                                .remove(item.id,
                                    item.amount,
                                    false)) {
                          owner.getActionSender()
                              .sendMessage(
                                  "It mixes to make some molten glass");
                          owner.getInventory().add(
                              623, 1, false);
                          owner.incExp(12, 20, true);
                          owner.getActionSender()
                              .sendStat(12);
                          owner.getActionSender()
                              .sendInventory();
                        }
                        owner.setBusy(false);
                      }
                    });
              } else {
                handleRegularSmelting();
              }
              break;
            case 50:
            case 177: // Anvil
              int minSmithingLevel = Formulae
                  .minSmithingLevel(item.id);
              if (minSmithingLevel < 0) {
                owner.getActionSender().sendMessage(
                    "Nothing interesting happens.");
                return;
              }
              if (owner.getInventory().countId(168) < 1) {
                owner.getActionSender()
                    .sendMessage(
                        "You need a hammer to work the metal with.");
                return;
              }
              if (owner.getCurStat(13) < minSmithingLevel) {
                owner.getActionSender().sendMessage(
                    "You need a smithing level of "
                        + minSmithingLevel
                        + " to use this type of bar");
                return;
              }
              options = new String[] { "Make Weapon",
                  "Make Armour", "Make Missile Heads",
                  "Cancel" };
              owner.setMenuHandler(new MenuHandler(options) {
                public void handleReply(int option, String reply) {
                  if (owner.isBusy()) {
                    return;
                  }
                  String[] options;
                  switch (option) {
                  case 0:
                    owner.getActionSender()
                        .sendMessage(
                            "Choose a type of weapon to make");
                    options = new String[] { "Dagger",
                        "Throwing Knife", "Sword",
                        "Axe", "Mace" };
                    owner.setMenuHandler(new MenuHandler(
                        options) {
                      public void handleReply(int option,
                          String reply) {
                        if (owner.isBusy()) {
                          return;
                        }
                        String[] options;
                        switch (option) {
                        case 0:
                          handleSmithing(item.id, 0);
                          break;
                        case 1:
                          if (Server.isMembers()) {
                            player.getActionSender()
                                .sendMessage(
                                    GameServer.P2P_LIMIT_MESSAGE);
                            break;
                          }
                          handleSmithing(item.id, 1);
                          break;
                        case 2:
                          owner.getActionSender()
                              .sendMessage(
                                  "What sort of sword do you want to make?");
                          options = new String[] {
                              "Short Sword",
                              "Long Sword (2 bars)",
                              "Scimitar (2 bars)",
                              "2-handed Sword (3 bars)" };
                          owner.setMenuHandler(new MenuHandler(
                              options) {
                            public void handleReply(
                                int option,
                                String reply) {
                              if (owner.isBusy()) {
                                return;
                              }
                              switch (option) {
                              case 0:
                                handleSmithing(
                                    item.id,
                                    2);
                                break;
                              case 1:
                                handleSmithing(
                                    item.id,
                                    3);
                                break;
                              case 2:
                                handleSmithing(
                                    item.id,
                                    4);
                                break;
                              case 3:
                                handleSmithing(
                                    item.id,
                                    5);
                                break;
                              default:
                                return;
                              }
                            }
                          });
                          owner.getActionSender()
                              .sendMenu(options);
                          break;
                        case 3:
                          owner.getActionSender()
                              .sendMessage(
                                  "What sort of axe do you want to make?");
                          options = new String[] {
                              "Hatchet",
                              "Pickaxe",
                              "Battle Axe (3 bars)" };
                          owner.setMenuHandler(new MenuHandler(
                              options) {
                            public void handleReply(
                                int option,
                                String reply) {
                              if (owner.isBusy()) {
                                return;
                              }
                              switch (option) {
                              case 0:
                                handleSmithing(
                                    item.id,
                                    6);
                                break;
                              case 1:
                                handleSmithing(
                                    item.id,
                                    7);
                                break;
                              case 2:
                                handleSmithing(
                                    item.id,
                                    8);
                                break;
                              default:
                                return;
                              }
                            }
                          });
                          owner.getActionSender()
                              .sendMenu(options);
                          break;
                        case 4:
                          handleSmithing(item.id, 9);
                          break;
                        default:
                          return;
                        }
                      }
                    });
                    owner.getActionSender().sendMenu(
                        options);
                    break;
                  case 1:
                    owner.getActionSender()
                        .sendMessage(
                            "Choose a type of armour to make");
                    options = new String[] { "Helmet",
                        "Shield", "Armour" };
                    owner.setMenuHandler(new MenuHandler(
                        options) {
                      public void handleReply(int option,
                          String reply) {
                        if (owner.isBusy()) {
                          return;
                        }
                        switch (option) {
                        case 0:
                          owner.getActionSender()
                              .sendMessage(
                                  "What sort of helmet do you want to make?");
                          options = new String[] {
                              "Medium Helmet",
                              "Large Helmet (2 bars)" };
                          owner.setMenuHandler(new MenuHandler(
                              options) {
                            public void handleReply(
                                int option,
                                String reply) {
                              if (owner.isBusy()) {
                                return;
                              }
                              switch (option) {
                              case 0:
                                handleSmithing(
                                    item.id,
                                    10);
                                break;
                              case 1:
                                handleSmithing(
                                    item.id,
                                    11);
                                break;
                              default:
                                return;
                              }
                            }
                          });
                          owner.getActionSender()
                              .sendMenu(options);
                          break;
                        case 1:
                          owner.getActionSender()
                              .sendMessage(
                                  "What sort of shield do you want to make?");
                          options = new String[] {
                              "Square Shield (2 bars)",
                              "Kite Shield (3 bars)" };
                          owner.setMenuHandler(new MenuHandler(
                              options) {
                            public void handleReply(
                                int option,
                                String reply) {
                              if (owner.isBusy()) {
                                return;
                              }
                              switch (option) {
                              case 0:
                                handleSmithing(
                                    item.id,
                                    12);
                                break;
                              case 1:
                                handleSmithing(
                                    item.id,
                                    13);
                                break;
                              default:
                                return;
                              }
                            }
                          });
                          owner.getActionSender()
                              .sendMenu(options);
                          break;
                        case 2:
                          owner.getActionSender()
                              .sendMessage(
                                  "What sort of armour do you want to make?");
                          options = new String[] {
                              "Chain Mail Body (3 bars)",
                              "Plate Mail Body (5 bars)",
                              "Plate Mail Legs (3 bars)",
                              "Plated Skirt (3 bars)" };
                          owner.setMenuHandler(new MenuHandler(
                              options) {
                            public void handleReply(
                                int option,
                                String reply) {
                              if (owner.isBusy()) {
                                return;
                              }
                              switch (option) {
                              case 0:
                                handleSmithing(
                                    item.id,
                                    14);
                                break;
                              case 1:
                                handleSmithing(
                                    item.id,
                                    15);
                                break;
                              case 2:
                                handleSmithing(
                                    item.id,
                                    16);
                                break;
                              case 3:
                                handleSmithing(
                                    item.id,
                                    17);
                                break;
                              default:
                                return;
                              }
                            }
                          });
                          owner.getActionSender()
                              .sendMenu(options);
                          break;
                        default:
                          return;
                        }
                      }
                    });
                    owner.getActionSender().sendMenu(
                        options);
                    break;
                  case 2:

                    if (Server.isMembers()) {
                      player.getActionSender()
                          .sendMessage(
                              GameServer.P2P_LIMIT_MESSAGE);
                      break;
                    }
                    options = new String[] {
                        "Make 10 Arrow Heads",
                        "Make 50 Arrow Heads (5 bars)",
                        "Forge Dart Tips", "Cancel" };
                    owner.setMenuHandler(new MenuHandler(
                        options) {
                      public void handleReply(int option,
                          String reply) {
                        if (owner.isBusy()) {
                          return;
                        }
                        switch (option) {
                        case 0:
                          handleSmithing(item.id, 18);
                          break;
                        case 1:
                          handleSmithing(item.id, 19);
                          break;
                        case 2:
                          handleSmithing(item.id, 20);
                          break;
                        default:
                          return;
                        }
                      }
                    });
                    owner.getActionSender().sendMenu(
                        options);
                    break;
                  default:
                    return;
                  }
                }
              });
              owner.getActionSender().sendMenu(options);
              break;
            case 121: // Spinning Wheel
              switch (item.id) {
              case 145: // Wool
                handleWoolSpinning();
                break;
              case 675: // Flax
                handleFlaxSpinning();
                break;
              default:
                owner.getActionSender().sendMessage(
                    "Nothing interesting happens.");
                return;
              }
              owner.setBusy(true);
              showBubble();
              owner.getActionSender().sendSound("mechanical");
              break;
            case 248: // Crystal key chest
              if (item.id != 525) {
                owner.getActionSender().sendMessage(
                    "Nothing interesting happens.");
                return;
              }
              if (!Server.isMembers()) {
                owner.getActionSender().sendMessage(
                    GameServer.P2P_LIMIT_MESSAGE);
                return;
              }
              owner.getActionSender().sendMessage(
                  "You use the key to unlock the chest");
              owner.setBusy(true);
              showBubble();
              Instance.getDelayedEventHandler().add(
                  new ShortEvent(owner) {
                    public void action() {
                      if (owner.getInventory()
                          .remove(item.id,
                              item.amount, false)) {
                        owner.getInventory().add(542,
                            1, false);
                        List<InvItem> loot = Formulae
                            .getKeyChestLoot();
                        for (InvItem i : loot) {
                          if (i.amount > 1
                              && !i.getDef()
                                  .isStackable()) {
                            owner.getInventory()
                                .add(i.id,
                                    i.amount,
                                    false);
                          } else {
                            if (i.id == 518
                                && i.amount > 20) {
                              i = new InvItem(
                                  518,
                                  DataConversions
                                      .random(0,
                                          20) + 1);
                            }
                            if (i.id == 517
                                && i.amount > 20) {
                              i = new InvItem(
                                  517,
                                  DataConversions
                                      .random(0,
                                          20) + 1);
                            }
                            Logger.println("Player: "
                                + owner.getUsername()
                                + " Got item: "
                                + i.id
                                + " From CHEST ("
                                + i.amount
                                + ") sys time ("
                                + GameEngine
                                    .getTimestamp()
                                + ")");
                            if (i.amount > 4000) {
                              Logger.println("WARNING!!!! Player: "
                                  + owner.getUsername()
                                  + " was about to get "
                                  + i.amount
                                  + " of "
                                  + i.id
                                  + " from the CHEST sys time ("
                                  + GameEngine
                                      .getTimestamp()
                                  + ")");
                              owner.setBusy(false);
                              owner.getActionSender()
                                  .sendInventory();
                              return;
                            }
                            owner.getInventory()
                                .add(i.id,
                                    i.amount,
                                    false);
                          }
                        }
                        owner.getActionSender()
                            .sendInventory();
                      }
                      owner.setBusy(false);
                    }
                  });
              break;
            case 302: // Sandpit
              if (item.id != 21) {
                owner.getActionSender().sendMessage(
                    "Nothing interesting happens.");
                return;
              }
              owner.getActionSender().sendMessage(
                  "You fill the bucket with sand.");
              owner.setBusy(true);
              showBubble();
              Instance.getDelayedEventHandler().add(
                  new MiniEvent(owner) {
                    public void action() {
                      if (owner.getInventory().remove(
                          item.id, 1, false)) {
                        owner.getInventory().add(625,
                            1, false);
                        owner.getActionSender()
                            .sendInventory();
                      }
                      owner.setBusy(false);
                    }
                  });
              break;
            case 179: // Potters Wheel
              if (item.id != 243) {
                owner.getActionSender().sendMessage(
                    "Nothing interesting happens.");
                return;
              }
              owner.getActionSender().sendMessage(
                  "What would you like to make?");
              options = new String[] { "Pot", "Pie Dish", "Bowl",
                  "Cancel" };
              owner.setMenuHandler(new MenuHandler(options) {
                public void handleReply(int option, String reply) {
                  if (owner.isBusy()) {
                    return;
                  }
                  int reqLvl, exp;
View Full Code Here

        Instance.getDelayedEventHandler().add(new MiniEvent(player) {
          public void action() {
            String[] options = new String[] { "Edgeville",
                "Karamja", "Draynor Village", "Al Kharid",
                "Seers", "Yanille" };
            owner.setMenuHandler(new MenuHandler(options) {
              public void handleReply(final int option,
                  final String reply) {
                if (owner.isBusy()
                    || owner.inCombat()
                    || !owner.getInventory().contains(
                        item.id)) {
                  return;
                }
                if (owner.getLocation().inModRoom()
                    && !owner.isMod()) {
                  owner.getActionSender()
                      .sendMessage(
                          "A magical force stops you from teleporting.");
                  return;
                }
                owner.getActionSender().sendSound("spellok");
                switch (option) {
                case 0: // Edgeville
                  owner.teleport(193, 435, true);
                  break;
                case 1: // Karamja
                  owner.teleport(360, 696, true);
                  break;
                case 2: // Draynor Village
                  owner.teleport(214, 632, true);
                  break;
                case 3: // Al Kharid
                  owner.teleport(72, 696, true);
                  break;
                case 4: // Seers
                  owner.teleport(516, 460, true);
                  break;
                case 5: // Yanille
                  owner.teleport(587, 761, true);
                  break;
                default:
                  return;

                }
                if (DataConversions.random(0, 5) == 1
                    && owner.getInventory().remove(item.id,
                        item.amount, false)) {
                  owner.getInventory().add(522, 1, false);
                  owner.getActionSender().sendInventory();
                }
              }
            });
            owner.getActionSender().sendMenu(options);
          }
        });
        break;
      case 316: // Ruby ammy
      case 317: // Diamond ammy
        if (!player.canLogout()
            || System.currentTimeMillis() - player.getLastMoved() < 10000) {
          player.getActionSender()
              .sendMessage(
                  "You must stand peacefully in one place for 10 seconds!");
          return;
        }
        player.getActionSender().sendMessage(
            "You rub the amulet... be careful!");
        player.getActionSender().sendMessage(
            "All who use this cursed amulet automatically skull!");
        Instance.getDelayedEventHandler().add(new MiniEvent(player) {
          public void action() {
            String[] options = new String[] { "Altar", "Castle" };
            owner.setMenuHandler(new MenuHandler(options) {
              public void handleReply(final int option,
                  final String reply) {
                if (owner.isBusy()
                    || owner.inCombat()
                    || !owner.getInventory().contains(
View Full Code Here

    }
    Instance.getDelayedEventHandler().add(new MiniEvent(player) {
      public void action() {
        String[] options = new String[] { "Beer Glass", "Vial", "Orb",
            "Cancel" };
        owner.setMenuHandler(new MenuHandler(options) {
          public void handleReply(final int option, final String reply) {
            InvItem result;
            int reqLvl, exp;
            switch (option) {
            case 0:
View Full Code Here

    }
    Instance.getDelayedEventHandler().add(new MiniEvent(player) {
      public void action() {
        String[] options = new String[] { "Arrow shafts", "Shortbow",
            "Longbow", "Cancel" };
        owner.setMenuHandler(new MenuHandler(options) {
          public void handleReply(final int option, final String reply) {
            InvItem result;
            int reqLvl, exp;
            switch (option) {
            case 0:
View Full Code Here

      player.getActionSender()
          .sendMessage("What would you like to make?");
      String[] optionsz = new String[] { "Bread Dough", "Pizza Base",
          "Pastry Dough" };

      player.setMenuHandler(new MenuHandler(optionsz) {
        public void handleReply(final int option, final String reply) {
          int newid = 0;
          if (option == 0) {
            newid = 137;
          } else if (option == 1) {
            newid = 321;
          } else if (option == 2) {
            newid = 250;
          } else {
            return;
          }
          if (owner.getInventory().remove(141, 1, false)
              && owner.getInventory().remove(136, 1, false)) {
            owner.getActionSender().sendMessage(
                "You create a " + reply);
            owner.getInventory().add(140, 1, false);
            owner.getInventory().add(135, 1, false);
            owner.getInventory().add(newid, 1, false);
            owner.getActionSender().sendInventory();
          }

        }
      });
      player.getActionSender().sendMenu(optionsz);
      return;
    }

    if (item1.id == 50 && item2.id == 136 || item1.id == 136
        && item2.id == 50) {
      player.getActionSender()
          .sendMessage("What would you like to make?");
      String[] optionsz = new String[] { "Bread Dough", "Pizza Base",
          "Pastry Dough" };
      player.setMenuHandler(new MenuHandler(optionsz) {
        public void handleReply(final int option, final String reply) {
          int newid = 0;
          if (option == 0) {
            newid = 137;
          } else if (option == 1) {
View Full Code Here

    }
    Instance.getDelayedEventHandler().add(new MiniEvent(player) {
      public void action() {
        String[] options = new String[] { "Armour", "Gloves", "Boots",
            "Cancel" };
        owner.setMenuHandler(new MenuHandler(options) {
          public void handleReply(final int option, final String reply) {
            InvItem result;
            int reqLvl, exp;
            switch (option) {
            case 0:
View Full Code Here

TOP

Related Classes of org.moparscape.msc.gs.model.MenuHandler

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.