Example #1
0
    @Override
    public int execute(MapleClient c, String[] splitted) {
      if (splitted.length < 2) {
        c.getPlayer().dropMessage(6, splitted[0] + " <数量> <道具名稱>");
        return 0;
      }
      final String itemName = StringUtil.joinStringFrom(splitted, 2);
      final short quantity = (short) CommandProcessorUtil.getOptionalIntArg(splitted, 1, 1);
      int itemId = 0;
      for (Pair<Integer, String> item : MapleItemInformationProvider.getInstance().getAllItems2()) {
        if (item.getRight().toLowerCase().equals(itemName.toLowerCase())) {
          itemId = item.getLeft();
          break;
        }
      }
      MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
      if (!ii.itemExists(itemId)) {
        c.getPlayer().dropMessage(5, itemName + "不存在");
      } else {
        Item toDrop;
        if (GameConstants.getInventoryType(itemId) == MapleInventoryType.EQUIP) {

          toDrop = ii.getEquipById(itemId);
        } else {
          toDrop = new client.inventory.Item(itemId, (byte) 0, quantity, (byte) 0);
        }
        toDrop.setGMLog(c.getPlayer().getName() + " 使用 " + splitted[0] + " 命令制作");
        toDrop.setOwner(c.getPlayer().getName());
        c.getPlayer()
            .getMap()
            .spawnItemDrop(
                c.getPlayer(), c.getPlayer(), toDrop, c.getPlayer().getPosition(), true, true);
      }
      return 1;
    }
Example #2
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   if (splitted.length < 2) {
     c.getPlayer().dropMessage(6, splitted[0] + " <道具ID> (数量:默认1)");
     return 0;
   }
   final int itemId = Integer.parseInt(splitted[1]);
   final short quantity = (short) CommandProcessorUtil.getOptionalIntArg(splitted, 2, 1);
   MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
   if (!ii.itemExists(itemId)) {
     c.getPlayer().dropMessage(5, itemId + "不存在");
   } else {
     Item toDrop;
     if (GameConstants.getInventoryType(itemId) == MapleInventoryType.EQUIP) {
       toDrop = ii.randomizeStats((Equip) ii.getEquipById(itemId));
     } else {
       toDrop = new client.inventory.Item(itemId, (byte) 0, quantity, (byte) 0);
     }
     toDrop.setGMLog(c.getPlayer().getName() + " 使用 " + splitted[0] + " 命令制作");
     // toDrop.setOwner(c.getPlayer().getName());
     c.getPlayer()
         .getMap()
         .spawnItemDrop(
             c.getPlayer(), c.getPlayer(), toDrop, c.getPlayer().getPosition(), true, true);
   }
   return 1;
 }